本文整理汇总了Java中uk.co.caprica.vlcj.player.MediaPlayer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayer.stop方法的具体用法?Java MediaPlayer.stop怎么用?Java MediaPlayer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uk.co.caprica.vlcj.player.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.stop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResolution
import uk.co.caprica.vlcj.player.MediaPlayer; //导入方法依赖的package包/类
private String getResolution(File file){
MediaPlayer player = EpisodePanel.player;
if(player.isPlaying()){
player.stop();
}
player.playMedia(file.getAbsolutePath());
player.mute(true);
while(player.getVideoDimension() == null){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
VideoTrackInfo track = (VideoTrackInfo) player.getTrackInfo(TrackType.VIDEO).get(0);
player.stop();
return track.height() + "P";
}
示例2: run
import uk.co.caprica.vlcj.player.MediaPlayer; //导入方法依赖的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: stop
import uk.co.caprica.vlcj.player.MediaPlayer; //导入方法依赖的package包/类
@Override
public void stop() {
lastPlayedMedia = null;
MediaPlayer mediaPlayer = _mediaPlayer;
if(mediaPlayer != null){
mediaPlayer.stop();
}
}
示例4: convertVideoToImages
import uk.co.caprica.vlcj.player.MediaPlayer; //导入方法依赖的package包/类
/**
* Converts the specified video file to a series of images and adds them to
* the given shared queue.
*
* @param f the video file
* @param singleImage whether just a single preview image is required
* @param sharedQueue the shared processing queue
* @throws IOException if there is a problem loading the media file
* @throws InterruptedException if loading is interupted
*/
public void convertVideoToImages(File f, boolean singleImage, final BlockingQueue<Image> sharedQueue, VideoLoadedLock videoLoadedLock) throws IOException, InterruptedException {
EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
JWindow frame = new JWindow();
frame.setBounds(0,0,1,1);
frame.add(mediaPlayerComponent);
frame.setVisible(true);
final MediaPlayer player = mediaPlayerComponent.getMediaPlayer();
player.mute();
player.playMedia(f.getAbsolutePath());
long len = player.getLength();
if (len == 0) {
Thread.sleep(MEDIA_PRELOAD_WAIT);
len = player.getLength();
}
int singleImageSelectionTime = -1;
if (singleImage) {
singleImageSelectionTime = new Random().nextInt(RANDOM_INTRO_WAIT) + MINIMUM_INTRO_WAIT;
if (singleImageSelectionTime > len) {
singleImageSelectionTime = (int) len-1;
}
}
frame.setVisible(false);
log.debug("Player time: {}, Len: {}", player.getTime(), len);
videoLoadedLock.preloadFinished();
try {
while (player.getTime() < len) {
if (cancel) {
break;
}
// Always add images if we don't want a single preview
// image or when the time exceeds the point we want a
// single image from
if (singleImageSelectionTime == -1 || player.getTime() >= singleImageSelectionTime) {
sharedQueue.add(player.getSnapshot());
// We only want one image if single image selection
// is turned on
if (singleImageSelectionTime != -1 && player.getTime() >= singleImageSelectionTime) {
break;
}
}
}
} finally {
player.stop();
player.release();
mediaPlayerComponent.release();
cancel = false;
}
}