How can I play videos with only a MediaPlayer?
I want to play two videos with only a MediaPlayer:private static MediaPlayerBuilder mpB;
private static Media mLogo;
private static Media mSaludo;
private static MediaPlayer mpLogo;
private static MediaView mvLogo;
private static Group gLogo;
public void start(final Stage stage) {
...
mLogo = MediaBuilder.create().source(myGetResource(VIDEOLOGO_PATH)).build();
mSaludo = MediaBuilder.create().source(myGetResource(VIDEOSALUDO_PATH)).build();
mpB = MediaPlayerBuilder.create();
mpLogo = mpB.media(mLogo).build();
mvLogo = MediaViewBuilder.create().mediaPlayer(mpLogo).build();
gLogo.getChildren().add(mvLogo);
...
sActual = new Scene(gPozos, WIDTH, HEIGHT, Color.BLACK);
stage.setScene(sActual);
stage.show();
When I want to play mLogo:sActual.setRoot(gLogo);
mpLogo.play();
Then, when I want to play mSaludo I do the following:mpLogo = mpB.media(mSaludo).build();
sActual.setRoot(gLogo);
mpLogo.play();
or this:mpB.media(mSaludo).applyTo(mpLogo);
sActual.setRoot(gLogo);
mpLogo.play();
or this:mpB.media(mSaludo);
sActual.setRoot(gLogo);
mpLogo.play();
But it is impossible to change the media. It does not work. Sometimes I play video mLogo and sometimes (according to the code) the video mLogo does not start and I see a picture of the first keyframe and nothing else. I have no exception, no error, nothing.I want to play mLogo, then mSaludo. How can I do this?
Thank you
Noelia
I want to play two videos with only a MediaPlayer
You can not.
MediaPlayer documentation: http://docs.oracle.com/javafx/2.0/api/javafx/scene/media/MediaPlayer.html#MediaPlayer (javafx.scene.media.Media)
"Create a player for a specific medium. This is the only way to associate a multimedia object with a MediaPlayer: once the player is created, it is not editable. The errors that occur synchronously within the constructor will cause exceptions to be thrown. The errors that occur asynchronously will cause the error to be together and therefore any recall onError property to call. "
I have no exception, no error, nothing.
Certain exceptions MediaPlayer, they occur asynchronously and you must explicitly add a listener for them, or you will never know that they occur.
Your code has additional problems, for example, you cannot change an object built from a manufacturer after the object has already been built.
--------
What you want to read a video with a single MediaView, and have the second video starts automatically after the first video is over. Note that it is the MediaView that is shared, not the MediaPlayers.
Here is an example for this.
public class TwoVideos extends Application {
public static void main(String[] args) throws Exception { launch(args); }
public void start(final Stage stage) throws Exception {
final StackPane layout = new StackPane();
// create some media players.
final MediaPlayer logoSrc = // first video is just 16sec (thank goodness...)
createPlayer("http://www.hackerdude.com/channels-test/20051210-w50s.flv");
final MediaPlayer soludoSrc =
createPlayer("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv");
// create a view to show the mediaplayers.
final MediaView mediaView = new MediaView(logoSrc);
// play the logo video, followed by the soludo video, followed by a finished message.
logoSrc.play();
logoSrc.setOnEndOfMedia(new Runnable() {
@Override public void run() {
mediaView.setMediaPlayer(soludoSrc);
soludoSrc.play();
}
});
soludoSrc.setOnEndOfMedia(new Runnable() {
@Override public void run() {
layout.getChildren().remove(mediaView);
layout.getChildren().add(new Label("All Done!"));
}
});
// layout the scene.
layout.setStyle("-fx-background-color: cornsilk; -fx-font-size: 20; -fx-padding: 10;");
layout.getChildren().addAll(mediaView);
Scene scene = new Scene(layout, 600, 400);
stage.setScene(scene);
stage.show();
}
/** @return a MediaPlayer for the given source which will report any errors it encounters */
private MediaPlayer createPlayer(String aMediaSrc) {
final MediaPlayer player = new MediaPlayer(new Media(aMediaSrc));
player.setOnError(new Runnable() {
@Override public void run() {
System.out.println("Media error occurred: " + player.getError());
}
});
return player;
}
}
On my machine (win7, javafx 2.0, jdk7), this example will not work correctly about 50% of the time, the rest of the time I get an error from the corruption of the media reported, I guess due to errors in the media stack, because it works sometimes. I'll try it again with the next 2.0.2 version JavaFX and report a Jira if it still does not work. You can try the code above with your videos, and if he does not report errors to the command line, then likely will work best for you.
Tags: Java
Similar Questions
-
How can I play videos with .xspf file extensions?
.xspf file extensions?
How can I play videos with .xspf file extensions?Wikipedia
"XML Shareable Playlist Format (XSPF), pronounced spiff, is an XML- based playlist format for digital media, sponsored by the Xiph.Org Foundation."XSPF is a data format for sharing the kind of playlist that can be played on a personal computer or a portable device. In the same way that any user on any computer can open any web page, XSPF is intended to provide portability of the selections. »
I hope this helps. Good luck.
-
How can I download videos with RealPlayer?
When I've upgraded to FireFox 13 my Plugin RealPlayer browser Record has been disabled as dangerous and unstable. Now I can't download videos that I watch with RealPlayer. When I activate the Plugin, I can't watch the video (I get a blank video screen). So, how can I download and save videos I want like those on the pulse of the planet by Rick Levine or other sites with recordable video? I downloaded and installed the latest version of RealPlayer and they say that I will be able to download videos but I can't. This problem is also related to this Plugin disabled?
Hi all Freaked Out Firefox and RealPlayer users,
This is the proper workaround for the problem of not being able to see videos after the Adobe defective 11.3 update (either the 11.3.300.257 or the latest 11.3.300.262) and not being able to download them with the RealPlayer Browser Record Plugin extension because Firefox disabled it.You can enable it but you won't be able to see videos unless you roll back the defective update and disabling the extension doesn't even work for some users to even let you see videos, much less download them. I successfully tested uninstalling adobe's update 11.3 and reinstalling with two different versions - 10.3 and 11.2 and posted this on other threads beginning 6/11. People who have tried it have been very grateful once they stopped listening to all the confusing and misleading recommendations by Firefox and Adobe. It's the ONLY one that gives full use of RealPlayer as well as updated security on the Flash Player and I've provided the most direct link to that version without having to download a cumbersome .zip file. It's a link to the 10.3 version. You will see other references to the 11.2 version on this thread. Although I tested that first and it works equally well, there are known critical vulnerabilities as reported by Secunia and Adobe,so I don't recommend it unless you have top security software. I do, and had no trouble with it. The 10.3, however, is up to date on security and works equally well -I've tested both. Just remember to enable the RealPlayer Browser Record Plugin extension after you roll back the update.
Alternatively, if you want, you can simply switch browsers 'till this is fixed. And for many of you for whom FF disabling the RealPlayer extension does not even work to allow you to see videos - it didn't for me, and a Level Three Case Manager I know at RealPlayer said the same thing- obviously it's not the best solution and even if it allows you to see videos, these geniuses at Firefox have not been even telling you how to then download videos with RealPlayer - they've been too busy following Adobe's "pass the buck and blame RealPlayer so just disable it" nonsense without telling what to do next, or that there are other much better choices. RealPlayer is likely not the cause (although there is a conflict in the interaction with the Adobe update.
The Best Choices are: First Choice: Roll Back the Update to the 10.3 version -
See links below for both Adobe's uninstaller - to first uninstall the 11.3- and for the 10.3 version. Choose the 10.3 that says "for other browsers"- this is for Firefox. The other one is for IE Active X. IE and has to be reinstalled also because the uninstaller removes both version.
Adobe clean uninstall instructions, step 4, which says to remove the additional files and folders is not usually necessary and you can be denied access to delete all files. RealPlayer also said it is not necessary. I know how to create special permissions but don't mind not because most of the users don't know how to do this - I didn't, even though I am almost certain that one of these Firefox gurus will tell you that I'm wrong. It's good to make the move, only, it can be difficult for many and it does not seem necessary for me or someone else, from what I've heard.
Note: When you reinstall the 10.3 change the update setting from automatic to "Never check for updates" to avoid any more problems until this is finally fixed. Adobe already updated to the 11.3.300.262 for Firefox (which was designed to ONLY fix the crash problems and not the video viewing problems) and didn't even fix that -I don't trust anything Adobe says right now until this is permanently fixed. And in the future I strongly urge you to do the same, keeping it on "Notify me if there are updates" in a future version where that choice is available. If you forget, you can change the setting from the control panel. Click on Large Icons, then Flash Player and on then the Advanced tab and dot the lower radio button for "Never check....." in the 10.3 If you don't get notified of a new version you can always check this forum which you need to do anyway because any new version at this point is going to be a beta version fix until we test it thoroughly and I don't care who disagrees with me on that, or what Firefox says either.
Second choice:
Change Browsers -
The Adobe problem involves only Firefox. You can watch videos and download them with the RealPlayer download button if you don't want to do the restore. You can even leave the extension off RealPlayer (if that allows to see the videos) and use another browser to download (just copy and paste the URL of the video on the address bar) and the RealPlayer download button will work.
To uninstall 11.3
http://forums.adobe.com/message/4041846#4041846
To install 10.3
http://forums.adobe.com/thread/889580 Important Note: Remember, you have to reinstall both versions, the one for Firefox and for Internet Explorer because the uninstaller removes both. This has worked perfectly for many others I've heard back from - hope it works for you.
-
How can I play videos Google from an ipad on a TV?
Wondering if anyone could tell me how I can play a movie I rented by Google play of a mini iPad on a Samsung TV? I use the official HDMI adapter from Apple, but I get an error message saying: it is not allowed to play videos's protégé. I guess it's the adapter, but appears to have only this problem with Google videos play. I have tested and can Netflix and Amazon Prime fine videos, and it plays movies iTunes without any problems. Don't know why Google Play is any different, unless Apple is not as her biggest rival used on THEIR products because they have cigarette butts. But it doesn't matter. XD
Its like everything is not working properly for me. Maybe you should contact Google given that is where you acquired the content you want to listen to.
-
How can I play video CDs in Windows 7?
My friend in the Philippines insists that I should be able to read these discs. But my PC or my player Blu - Ray will recognize them.
Is there something I can do to be able to read them?
My friend in the Philippines insists that I should be able to read these discs. But my PC or my player Blu - Ray will recognize them.
Is there something I can do to be able to read them?
=========================================
It is possible that the free VLC Media Player would be
recognize the VCDs.(FWIW... it's always a good idea to create a system)
Restore point before installing software or updates)VLC Media Player (32-bit)
http://www.filehippo.com/download_vlc_32/
(works on XP/Vista/7)
(the name of the file to download is: vlc - 2.0.4 - win32.exe)VLC Media Player (64-bit)
http://www.filehippo.com/download_vlc_64/
(the name of the file to download is: vlc - 2.0.4 - win64.exe)
(FWIW... it's always a good idea to create a system)
Restore point before installing software or updates)The following link might be worth a visit:
How to play VCD filesIn addition, some free-standing DVD players will play VCDS if
you have connected to the TV, it may be worth trying. -
How can I play videos full screen to intex nails fx... cell os firefox?
Model: intex cloud fx
ritzz says
Model: intex cloud fx
In settings, go to the view tab and uncheck the lock orientation . After that just go to the video you want to play and tilt the mobile in the desired direction.
I hope this will solve your problem.
-
Unable to play videos with. VOB extensions on my pc with Windows 7
I have Windows 7. Have Window Media Player 12? If so, I can't play videos with. VOB extensions. Trying to find an answer that follows was a possible solution via the MS Community answers: go to all programs, WMP, tools, options and drive tab, then select the "codec download automatically in auto updates, but I don't see that when I follow these steps? Seen another article that says to change the. Extension VOB to an mpg? Can you help me to find a better way to fix this? What can I do to be able to play videos with. VOB extensions? Thank you.
I have Windows 7. Have Window Media Player 12? If so, I can't play videos with. VOB extensions. Trying to find an answer that follows was a possible solution via the MS Community answers: go to all programs, WMP, tools, options and drive tab, then select the "codec download automatically in auto updates, but I don't see that when I follow these steps? Seen another article that says to change the. Extension VOB to an mpg? Can you help me to find a better way to fix this? What can I do to be able to play videos with. VOB extensions? Thank you.
Download and install VLC Player.
-
How can I play multiple instances of video (no problem reading of 12 movies at the same time, at the opening of the 13th film the problem only starts), the classic use of media player in windows XP? I was able to do all the time! It has to do with the codec?
If yes what codec plays multiple instances of Media Player Classic in windows XP?
I get the same problem with VLC all that needs to be checked on preferences is checked in the two VLC & MPC!Hello
Multiple instances of Media Player is not supported in version 7 and greater.
· What version of Windows Media Player you have installed?
· Are instances that you are referring to the bodies shipped?
· You use any third-party software to run multiple instances?
-
I can't play video of videomega.tv on mozilla, but when I use chrome, it works. On mozilla that it still can not be charged, said just because the server or network failed, or may format not supported. I have already updated to flash player and use html5 extension, without result. How to solve this problem? Thank you...
Thank you for your advice, but when I checked it on topic: config, the value is 2, so I don't change anything.
When I search another solution, accidentally, I installed engine (socialmedia.com) unwanted search so I am forced to reset mozilla. After that, the two problem solved all of a sudden!
Thanks for all your help and advice, it is very appreciated by me.
-
How can I play a dvd blue-ray on a Macbook with a great player?
How can I play a dvd blue-ray on a Macbook pro with a great player? I am running 10.11.5 of El Capitan on a MacBook Pro (retina, 15 inches, end of 2013). The Superdrive rejects the dvd blue-ray.
Super disks are not compatible with Blu Ray - you'll need to get a dedicated Blu Ray player
-
Problem with iTunes 12.3.2.35, other titles are visible, but will not play. How can I play? Thank you
Can you describe what happens when you try to play these tracks? Do you have an error message (If Yes, what does say)? Are the visible but greyed out? They were a symbol of an exclamation mark next to them?
-
How can I play DVDs from my hard drive with windows XP?
How can I play DVDs from my hard drive with windows XP?
If you have a decdoer of installed dvd, usually with packages like power dvd etc that allow you to watch a dvd in your dvd drive, and then later versions of Media Player will also play your DVDs, and all of these programs that play said removable DVD.
-
How can I upload videos taken with my iphone to my computer?
How can I upload videos taken with my iphone to my computer?
When the phone is connected to the PC via USB...
If you go to... Start / my computer... is the phone
listed as a removable drive?If_Yes_right click on the drive letter for the phone
and choose... Open or explore... and should be
display the directory of the memory card.You can copy and paste or drag and drop your files
from there to a folder on your hard drive. -
How can I play flac Audio files with extension on windows media player
How can I play flac Audio files with extension on windows media player
Hello jesskenneth,
Thank you for visiting the Microsoft answers Site.
The extension Flac is not a type of supported Windows Media Player file. However, you can user your favorite search engine to search for a solution that can convert the file in a supported file type Windows Media Player.
For more information on the types of files supported by Windows Media Player, you can also view the following link:
Information on the types of media files that supports Windows Media Player
Thank you
Mary
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
How can I install CS6 with serial number only. You sent me?
How can I install CS6 with serial number only. You sent me?
You can download any product CS6, you speak from the page linked below. The serial number can be used to enable as part of the installation.
http://helpx.Adobe.com/x-productkb/policy-pricing/CS6-product-downloads.html
Maybe you are looking for
-
The PC HP Pavilion Sleekbook 15: Blurred and static Audio after update of Windows 10
I was using Windows 10 quite a few months now with no problems. My sound has been clear until this morning when my computer automatically updated itself. After the update, I noticed that my sound (which worked perfectly fine before the update) was bl
-
Distinction with iPhoto Albums?
I have recently converted to pictures and there is a folder called iPhoto events that has all my old iPhoto albums events. Can I just drag these albums outside of this folder and put on my list of the albums separately and use them as any other albu
-
Problems connecting to Windows Live Messenger 2011
Hello I was wondering if someone can help me with this request. I downloaded the new Windows Live Messenger 2011, but I get this error message whenever I'm trying to connect. "Windows Live Messenger has stopped working. A problem caused the blocking
-
Windows XP don't talk to the PS3
I have windows XP and trying to get the computer talk to him about the PS3 for media sharing. The last few days while pretending to have all the boxes are checked on the computer and with WMP11 and all the setting supposed to be correct in the PS3 ca
-
This icon has been installed by the program provided with the Seagate external hard drive. Whenever I shut off the computer, it generates an error, so I would stop it. I can still run the program by Seagate manually when I need it (when I backup my