Commit 794a6935 authored by Filippo Carone's avatar Filippo Carone

fixes for libvlc medialistplayer_play_item and...

fixes for libvlc medialistplayer_play_item and medialistplayer_play_item_at_index - medialistplayer_play is still out of order
parent 9806c813
/*****************************************************************************
* LibVlcState.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
package org.videolan.jvlc.internal;
public enum LibVlcState
{
libvlc_NothingSpecial,
libvlc_Stopped,
libvlc_Opening,
libvlc_Buffering,
libvlc_Ended,
libvlc_Error,
libvlc_Playing,
libvlc_Paused
}
......@@ -110,10 +110,10 @@ public class MediaListPlayerTest
Assert.assertEquals(1, exception.raised);
}
// @Test
/**
* disabled: see https://trac.videolan.org/vlc/attachment/ticket/1527
* this fails: see https://trac.videolan.org/vlc/attachment/ticket/1527
*/
@Test
public void mediaListPlayerPlay()
{
libvlc_exception_t exception = new libvlc_exception_t();
......@@ -123,6 +123,41 @@ public class MediaListPlayerTest
libvlc.libvlc_media_list_add_media_descriptor(mediaList, mediaDescriptor, exception);
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
libvlc.libvlc_media_list_player_play(mediaListPlayer, exception);
Assert.assertEquals("Exception message: " + exception.message + ".\n", 0, exception.raised);
}
@Test
public void mediaListPlayerPlayItemAtIndex()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
LibVlcMediaDescriptor mediaDescriptor = libvlc.libvlc_media_descriptor_new(libvlcInstance, mrl, exception);
libvlc.libvlc_media_list_add_media_descriptor(mediaList, mediaDescriptor, exception);
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
libvlc.libvlc_media_list_player_play_item_at_index(mediaListPlayer, 0, exception);
}
@Test
public void mediaListPlayerPlayItem() throws Exception
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
LibVlcMediaDescriptor mediaDescriptor = libvlc.libvlc_media_descriptor_new(libvlcInstance, mrl, exception);
libvlc.libvlc_media_list_add_media_descriptor(mediaList, mediaDescriptor, exception);
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
libvlc.libvlc_media_list_player_play_item(mediaListPlayer, mediaDescriptor, exception);
Thread.sleep(6000);
}
@Test
public void mediaListPlayerGetStateStopped()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception);
Assert.assertEquals(LibVlcState.libvlc_Stopped.ordinal(), state);
}
}
......@@ -41,6 +41,11 @@ get_next_path( libvlc_media_list_player_t * p_mlp )
libvlc_media_list_t * p_parent_of_playing_item;
libvlc_media_list_t * p_sublist_of_playing_item;
if ( !p_mlp->current_playing_item_path )
{
p_mlp->current_playing_item_path = libvlc_media_list_path_empty();
}
p_sublist_of_playing_item = libvlc_media_list_sublist_at_path(
p_mlp->p_mlist,
p_mlp->current_playing_item_path );
......@@ -149,6 +154,11 @@ install_playlist_observer( libvlc_media_list_player_t * p_mlp )
static void
uninstall_playlist_observer( libvlc_media_list_player_t * p_mlp )
{
if ( !p_mlp->p_mlist )
{
return;
}
libvlc_event_detach( libvlc_media_list_event_manager( p_mlp->p_mlist, NULL ),
libvlc_MediaListItemDeleted, mlist_item_deleted, p_mlp, NULL );
}
......@@ -171,6 +181,11 @@ install_media_instance_observer( libvlc_media_list_player_t * p_mlp )
static void
uninstall_media_instance_observer( libvlc_media_list_player_t * p_mlp )
{
if ( !p_mlp->p_mi )
{
return;
}
libvlc_event_detach( libvlc_media_instance_event_manager( p_mlp->p_mi, NULL ),
libvlc_MediaInstanceReachedEnd,
media_instance_reached_end, p_mlp, NULL );
......@@ -204,6 +219,12 @@ set_current_playing_item( libvlc_media_list_player_t * p_mlp,
/* We are not interested in getting media_descriptor stop event now */
uninstall_media_instance_observer( p_mlp );
if ( !p_mlp->p_mi )
{
p_mlp->p_mi = libvlc_media_instance_new_from_media_descriptor(p_md, p_e);
}
if( p_md->p_subitems && libvlc_media_list_count( p_md->p_subitems, NULL ) > 0 )
{
libvlc_media_descriptor_t * p_submd;
......@@ -218,8 +239,6 @@ set_current_playing_item( libvlc_media_list_player_t * p_mlp,
vlc_mutex_unlock( &p_mlp->object_lock );
libvlc_media_list_unlock( p_mlp->p_mlist );
libvlc_media_descriptor_release( p_md ); /* for libvlc_media_list_item_at_index */
}
......@@ -413,7 +432,10 @@ void libvlc_media_list_player_play_item(
void libvlc_media_list_player_stop( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e )
{
if ( p_mlp->p_mi )
{
libvlc_media_instance_stop( p_mlp->p_mi, p_e );
}
vlc_mutex_lock( &p_mlp->object_lock );
free( p_mlp->current_playing_item_path );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment