本文整理汇总了Java中uk.co.caprica.vlcj.player.MediaPlayer类的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayer类的具体用法?Java MediaPlayer怎么用?Java MediaPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaPlayer类属于uk.co.caprica.vlcj.player包,在下文中一共展示了MediaPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: playing
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
public void playing(MediaPlayer mediaPlayer) {
if (msPerFrame <= 0) {
float fps = mediaPlayer.getFps();
if (fps > 1) {
msPerFrame = (1000d / fps);
stdev = msPerFrame / 2;
}
}
List<IMediaPlayerListener> localObservers;
synchronized(MUTEX) {
localObservers = new ArrayList<IMediaPlayerListener>(observers);
}
for(IMediaPlayerListener l : localObservers){
l.mediaStarted();
}
}
示例3: mediaStateChanged
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void mediaStateChanged(MediaPlayer mediaPlayer, int newState) {
super.mediaStateChanged(mediaPlayer, newState);
logger.debug("New State " + newState);
Display display = Display.getDefault();
//listener to handle displaying a new page when the audio ends
if ((newState==6) && isPlaying){
if (!target.equals("")) {
//run on the main UI thread
display.syncExec(
new Runnable() {
public void run(){
mainShell.runJscript(jscript, false);
mainShell.displayPage(target);
}
});
}
ComonFunctions comonFunctions = ComonFunctions.getComonFunctions();
comonFunctions.processSrciptVars(scriptVar, mainShell.getGuideSettings());
isPlaying = false;
}
display = null;
}
示例4: finished
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void finished(MediaPlayer mediaPlayer) {
logger.debug("MediaListener finished");
super.finished(mediaPlayer);
try {
//run on the main UI thread
myDisplay.syncExec(
new Runnable() {
public void run(){
mediaPanel.setVisible(false);
imageLabel.setVisible(true);
leftFrame.layout(true);
}
});
}
catch (Exception ex) {
logger.error(" MediaListener finished " + ex.getLocalizedMessage(), ex);
}
}
示例5: mediaStateChanged
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void mediaStateChanged(MediaPlayer lmediaPlayer, int newState) {
super.mediaStateChanged(lmediaPlayer, newState);
logger.debug("MediaListener newState: " + newState + " videoPlay: " + videoPlay + " VideoTarget: " + videoTarget);
try {
if ((newState==5 || newState==6) && videoPlay){
if (!videoTarget.equals("")) {
//run on the main UI thread
myDisplay.syncExec(
new Runnable() {
public void run(){
logger.debug("MediaListener Video Run: " + videoJscript + " videoTarget: " + videoTarget);
mainShell.runJscript(videoJscript, false);
mainShell.displayPage(videoTarget);
}
});
}
comonFunctions.processSrciptVars(videoScriptVar, guideSettings);
}
} catch (Exception e) {
logger.error("mediaStateChanged " + e.getLocalizedMessage(), e);
}
}
示例6: playing
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void playing(MediaPlayer mediaPlayer) {
stop.setEnabled(true);
stop.setText("❚❚");
long len = PLAYER.getLength();
timeSlider.setMaximum((int) TimeUnit.MILLISECONDS.toSeconds(len));
max.setText(TimeUnit.MILLISECONDS.toHours(len) +
":" +
TimeUnit.MILLISECONDS.toMinutes(len) +
":" +
TimeUnit.MILLISECONDS.toSeconds(len));
}
示例7: finished
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void finished(MediaPlayer mediaPlayer) {
stop.setEnabled(false);
stop.setText("▶");
timeSlider.setValue(0);
component.getVideoSurface().repaint();
}
示例8: 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);
}
示例9: timeChanged
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
public void timeChanged(MediaPlayer mediaPlayer, long newTime) {
if (msPerFrame <= 0) {
float fps = mediaPlayer.getFps();
if (fps > 1) {
msPerFrame = (1000d / fps);
stdev = msPerFrame / 2;
}
}
mediaTimeChanged();
}
示例10: paused
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void paused(MediaPlayer arg0) {
List<IMediaPlayerListener> localObservers;
synchronized(MUTEX) {
localObservers = new ArrayList<IMediaPlayerListener>(observers);
}
for(IMediaPlayerListener l : localObservers){
l.mediaPaused();
}
}
示例11: finished
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void finished(MediaPlayer mediaPlayer) {
// Used for YouTube videos
List<String> subItems = mediaPlayer.subItems();
if (subItems != null && !subItems.isEmpty()) {
String subItemURI = subItems.get(0);
mediaPlayer.playMedia(subItemURI);
} else {
renderer.setState(RendererState.STOPPED);
}
}
示例12: playing
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void playing(MediaPlayer mediaPlayer) {
renderer.setState(RendererState.PLAYING);
long position = getSeekPosition();
if (position > 0) {
mediaPlayer.setTime(position);
}
}
示例13: playMedia
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void playMedia(String file) {
lastPlayedMedia = file;
// vlc(j) path fix
file = file.replace("file:/", "file:///");
MediaPlayer mediaPlayer = _mediaPlayer;
if(mediaPlayer != null){
boolean success = mediaPlayer.playMedia(file);
logger.debug("playMedia succeeded? " + success + " - playing file: " + file);
}else{
logger.error("Media player not available!");
}
}
示例14: setCropGeometry
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void setCropGeometry(String aspectRatio) {
MediaPlayer mediaPlayer = _mediaPlayer;
if(mediaPlayer != null){
mediaPlayer.setCropGeometry(aspectRatio);
}else {
logger.error("media player not available!");
}
}
示例15: setScale
import uk.co.caprica.vlcj.player.MediaPlayer; //导入依赖的package包/类
@Override
public void setScale(float factor){
MediaPlayer mediaPlayer = _mediaPlayer;
if(mediaPlayer != null){
mediaPlayer.setScale(factor);
logger.debug("scale set to " + factor + " scale is now " + mediaPlayer.getScale());
}else {
logger.error("Media player not available!");
}
}