import junit.framework.Assert;
+import org.junit.After;
import org.junit.Test;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
public class MediaListPlayerTest extends AbstractVLCInternalTest
{
+
+ private LibVlcMediaListPlayer current;
+
@Test
public void mediaListPlayerNewTest()
{
/**
* this fails: see https://trac.videolan.org/vlc/ticket/1527
*/
- // @Test
+ @Test
public void mediaListPlayerPlay()
{
libvlc_exception_t exception = new libvlc_exception_t();
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
+ current = mediaListPlayer;
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
LibVlcMediaDescriptor mediaDescriptor = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
libvlc.libvlc_media_list_add_media(mediaList, mediaDescriptor, exception);
Thread.sleep(150);
}
libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception);
+ while (libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception) != LibVlcState.libvlc_Ended
+ .ordinal())
+ {
+ Thread.sleep(100);
+ }
libvlc.libvlc_media_release(mediaDescriptor);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
Thread.sleep(150);
}
- // FIXME give stats the time to run... there's probably a race condition in misc/stats.c:259 that
- // needs to be fixed
- // Thread.sleep(400);
+ Thread.sleep(400);
libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
Thread.sleep(150);
}
libvlc.libvlc_media_list_player_pause(mediaListPlayer, exception);
- Assert.assertEquals(exception.message, 0, exception.raised);
- while (true)
- {
- int playing = libvlc.libvlc_media_list_player_is_playing(mediaListPlayer, exception);
- if (exception.raised == 1)
- {
- throw new RuntimeException("Native exception thrown");
- }
- if (playing == 0)
- {
- break;
- }
- Thread.sleep(150);
- }
+
int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception);
Assert.assertEquals(exception.message, 0, exception.raised);
Assert.assertEquals(
libvlc.libvlc_media_list_release(mediaList);
}
+ @Override
+ @After
+ public void tearDown()
+ {
+ if (current != null)
+ {
+ libvlc.libvlc_media_list_player_stop(current, exception);
+ while (libvlc.libvlc_media_list_player_get_state(current, exception) != LibVlcState.libvlc_Ended.ordinal())
+ {
+ try
+ {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException e)
+ {
+ //
+ }
+ }
+ }
+ current = null;
+ super.tearDown();
+ }
+
}