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.