Java Vlcj - How to change media in EmbbededMediaPlayerComponent

混江龙づ霸主 提交于 2020-01-06 07:11:26

问题


So I have a EmbbededMediaPlayerComponent and Javafx list full of urls which can be played in EmbbededMediaPlayerComponent. The one on which you click is then supposed to be played in EmbbededMediaPlayerComponent. The first url you choose works just fine and is displayed in the player. The thing is, after I choose another url I want the first one to be replaced with the second one. What is the correct way to dispose the first media and then play the second one?


回答1:


I'm not sure if it's the "correct" way to do it but I would do:

EmbeddedMediaPlayerComponent.getMediaPLayer().playMedia(mrlToMedia);

If I have understood correctly this should just load the next file and start playing that one.

It's also possible to use

EmbeddedMediaPlayerComponent.getMediaPLayer().startMedia(String mrl);

which should try to start the playback with the difference that this is a blocking operation untill playback has started.

Also possible to do

EmbeddedMediaPlayerComponent.getMediaPLayer().prepareMedia(String mrl);
EmbeddedMediaPlayerComponent.getMediaPLayer().start();

This is the same as the one above but in two steps.




回答2:


All you need to do is this:

mediaPlayerComponent.getMediaPlayer().playMedia(mrl);

Which should be exactly the same as how you played your initial media.



来源:https://stackoverflow.com/questions/48312182/java-vlcj-how-to-change-media-in-embbededmediaplayercomponent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!