1 /*****************************************************************************
2 * LibVlcMediaInstanceTest.java: VLC Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 package org.videolan.jvlc.internal;
28 import org.junit.Assert;
29 import org.junit.Test;
30 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
31 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
34 public class LibVlcMediaPlayerTest extends AbstractVLCInternalTest
37 public void mediaInstanceNew()
39 LibVlcMediaInstance instance = libvlc.libvlc_media_player_new(libvlcInstance, exception);
40 Assert.assertNotNull(instance);
41 Assert.assertEquals(0, exception.raised);
45 public void mediaInstancePlayBad()
47 LibVlcMediaInstance instance = libvlc.libvlc_media_player_new(libvlcInstance, exception);
48 libvlc.libvlc_media_player_play(instance, exception);
49 Assert.assertEquals(1, exception.raised); // no associated media descriptor
53 public void mediaInstancePlay()
55 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
56 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
57 libvlc.libvlc_media_player_play(mi, exception);
58 Assert.assertEquals(0, exception.raised);
62 public void mediaInstancePauseBad()
64 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
65 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
66 libvlc.libvlc_media_player_pause(mi, exception);
67 Assert.assertEquals(1, exception.raised);
71 public void mediaInstancePause()
73 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
74 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
75 libvlc.libvlc_media_player_play(mi, exception);
76 libvlc.libvlc_media_player_pause(mi, exception);
77 Assert.assertEquals(0, exception.raised);
81 public void mediaInstanceSetPosition()
83 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
84 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
85 libvlc.libvlc_media_player_play(mi, exception);
86 libvlc.libvlc_media_player_set_position(mi, 0.5f, exception);
87 Assert.assertEquals(0, exception.raised);
88 float position = libvlc.libvlc_media_player_get_position(mi, exception);
89 Assert.assertTrue("Position is: " + position, position >= 0.5f);
93 public void mediaInstanceStop()
95 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
96 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
97 libvlc.libvlc_media_player_stop(mi, exception);
98 Assert.assertEquals(0, exception.raised);
102 public void mediaInstanceStop2() throws Exception
104 LibVlcMediaDescriptor md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
105 LibVlcMediaInstance mi = libvlc.libvlc_media_player_new_from_media(md, exception);
106 libvlc.libvlc_media_player_play(mi, exception);
108 libvlc.libvlc_media_player_stop(mi, exception);
109 Assert.assertEquals(0, exception.raised);