http://www.developer.com/http://www.developer.com/java/web/javafx-2-vs.-html5-media-support-for-ria.html
JavaFX 2 offers a rich set of graphics and media APIs. When combined with high-performance hardware accelerated graphics and media engines, the Java client platform enables developers to create high-performance rich Internet applications (RIAs) that behave consistently across multiple platforms. Gone are the days of scripting hell for Java developers, who can now use JavaFX 2 to inject new life into their applications. HTML5 is another blossoming technology in the arena of media streaming. The primary focus of HTML5 was leveraging media streaming to create better user experiences -- a domain so long dominated by Adobe Flash. Though the dust has not yet settled in the standard acceptability of media file formats, I believe JavaFX 2 and HTML5 will be worthy competitors in the RIA development arena. In this article, I describe the media assets in JavaFX 2.0 and compare them to the equivalent assets in HTML5. JavaFX 2 has the following codec support for audio streaming: JavaFX 2 has the following codec support for video streaming: For more information regarding codecs supported by JavaFX 2.1, review the system requirements documentation and the release notes. Besides limitations in browser support, HTML5 has similar issues as JavaFX in supporting audio/video formats. For more information on these issue, read How to embed video in HTML5. JavaFX media support is based on the following classes under the package java.scene.media. Here the steps for incorporating media in JavaFX: Here is a screenshot of the output from the above code. Incorporating media in HTML5 is simple and straightforward. The Optional attributes may be used with Here is a screenshot from a sample Web page with video embedded in HTML5. Similarly, the Here are some optional attributes that may be used with the The HTML5 DOM for audio/video has methods, properties, and events for the JavaFX and HTML5 face a few main challenges in trying to support media encoding: Do these challenges end up raising the same age-old problem of that plugins do, which these two technologies are trying overcome? Time will tell. Average developers do not like to concern themselves with what technology supports what encoding technique. They just want their applications to function well, at least in the sense that the applications support most of the available media file formats. Since JavaFX is a pure programming language, creating a customized media player would be easy for a developer. The same is not true for HTML5, which in addition to the codec support challenges also contends with limitations in browser support. The only consolation seems to be that both are young technologies with the opportunity to resolve these issues.
JavaFX 2 vs. HTML5: Media Support for RIA
June 6, 2012
JavaFX vs. HTML5: Media Steaming
When trying to play back video files in JavaFX, user should be conscious of the format they are trying to play. For example, the media format commonly found on YouTube or Metacafe -- especially the FLV files -- have some issues in JavaFX. JavaFX does not yet support playback of formats that adhere to Sorenson FLV. Also JavaFX still does not have any interface to return a list of supported formats and encodings.
JavaFX vs. HTML5: Incorporating Media
play() and stop() controls at runtime. AudioClipobjects are better suited for short-playing sounds.AudioClip audioClip=new AudioClip(source); audioClip.play();
MediaPlayer.getAudioEquilizer() returns an ObservableList of EquilizerBand elements, which can be used for audio equalization.
Media(String source)-- takes the source parameter as URI. However, if you want to play back media from your local computer, instantiate the Media object as follows:Media(new java.io.File(filePath).toURI().toString());
public void start(Stage stage) {
// Create and set the Scene.
Scene scene = new Scene(new Group(), 540, 209);
stage.setScene(scene);
stage.show();
// Create the media source. The source may be an URI or local file
// for local file
// String source=new File("c:/abc.flv"").toURI().toString());
// for URI file
// String source="http:/aaa/xyz/abc.flv";
Media media = new Media(source);
// Create the player and set to play automatically.
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
// Create the view and add it to the Scene.
MediaView mediaView = new MediaView(mediaPlayer);
((Group) scene.getRoot()).getChildren().add(mediaView);
}
<video> tag can be used to embed video/movie on the Web page as follows:<video width="320" height="240" controls="controls">
<source src="mymovie.mp4" type="video/mp4" />
<source src="mymovie.ogg" type="video/ogg" />
Browser does not support the video tag.
</video><video> element:
autoplay="autoplay" -- specifies that the video will start playing as soon as it is readycontrols="controls" -- specifies that video controls such as a play/pause buttonheight="pixels value" -- sets the height of the video playerwidth="pixels value" -- sets the width of the video playerloop="loop" -- specifies that the video will start over again, every time it is finishedmuted="muted" -- specifies that the audio output of the video should be mutedposter="URL" -- specifies an image to be shown while the video is downloading, or until the user hits the play buttonpreload= "auto/metadata/none" -- specifies if and how the author thinks the video should be loaded when the page loadssrc="URL" -- specifies the URL of the video file<audio> tag can be used to embed audio/music on the Web page as follows:<audio controls="controls">
<source src="mymusic.ogg" type="audio/ogg" />
<source src="mymusic.mp3" type="audio/mpeg" />
Browser does not support the audio element.
</audio><audio> element:
autoplay="autoplay" -- specifies that the video will start playing as soon as it is readycontrols="controls" -- specifies that video controls such as a play/pause buttonloop="loop" -- specifies that the video will start over every time it is finishedpreload= "auto/metadata/none" -- specifies if and how the author thinks the video should be loaded when the page loadssrc="URL" -- specifies the URL of the video file<audio> and <video> elements, which can be accessed through JavaScript.Conclusion