本文整理汇总了Java中uk.co.caprica.vlcj.player.MediaPlayerEventAdapter类的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayerEventAdapter类的具体用法?Java MediaPlayerEventAdapter怎么用?Java MediaPlayerEventAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaPlayerEventAdapter类属于uk.co.caprica.vlcj.player包,在下文中一共展示了MediaPlayerEventAdapter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMediaPlayerEventListener
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter; //导入依赖的package包/类
/**
* Adds the media player event listener.
*
* @param mediaPlayerEventAdapter
* the media player event adapter
*/
public void addMediaPlayerEventListener(MediaPlayerEventAdapter mediaPlayerEventAdapter)
{
if (initiated)
{
mediaPlayer.addMediaPlayerEventListener(mediaPlayerEventAdapter);
}
else
{
eventHandlersToAdd.add(mediaPlayerEventAdapter);
}
}
示例2: run
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter; //导入依赖的package包/类
public void run(String file) throws Exception {
MediaPlayer player = mediaPlayerFactory.newHeadlessMediaPlayer();
// TODO: change the listener
player.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
@Override
public void finished(uk.co.caprica.vlcj.player.MediaPlayer mediaPlayer) {
LOGGER.info("stream finished");
}
});
String mrl = "rtsp://:8554/vlc";
// TODO: allow display and save file at same time
// String options = ":sout=#transcode{vcodec=h264,venc=x264{cfr=16},scale=1,acodec=mp4a,ab=160,channels=2,samplerate=44100}:file{dst=D:/pt/t.mp4}";
player.playMedia(mrl, getOptions(file));
boolean shouldStop = false;
while (!shouldStop) {
Thread.sleep(1000);
LOGGER.debug("waiting for vlc to finish receiving stream");
if (player.getTime() == -1) {
player.stop();
player.release();
shouldStop = true;
}
}
mediaPlayerFactory.release();
writeFinishFlag(file);
}
示例3: addMediaPlayerEventListener
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter; //导入依赖的package包/类
/**
* Adds the media player event listener.
*
* @param mediaPlayerEventAdapter
* the media player event adapter
*/
public void addMediaPlayerEventListener(MediaPlayerEventAdapter mediaPlayerEventAdapter);