Ahsan Sadeeb
Ahsan Sadeeb

Reputation: 79

How can I integrate a flash player plugin to a Web Browser I have created using JavaFX?

I have created a web browser using JavaFX which supports HTML5 and JS but I can't watch videos.What can I do to integrate a flash player plugin to my browser?

Upvotes: 0

Views: 83

Answers (1)

mrsus
mrsus

Reputation: 5486

Hope this helps!

Here are the steps for incorporating media in JavaFX:

1) Create a Media object with appropriate source 2) Create a MediaPlayer object from the Media object. 3) Create a MediaView object like this:

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); 

} Here is a screenshot of the output from the above code.

enter image description here

Incorporating media in HTML5 is simple and straightforward. The tag can be used to embed video/movie on the Web page as follows:

  <source src="mymovie.mp4" type="video/mp4" />

  <source src="mymovie.ogg" type="video/ogg" />

Optional attributes may be used with element:

autoplay="autoplay" -- specifies that the video will start playing as soon as it is ready

controls="controls" -- specifies that video controls such as a play/pause button

height="pixels value" -- sets the height of the video player

width="pixels value" -- sets the width of the video player

loop="loop" -- specifies that the video will start over again, every time it is finished

muted="muted" -- specifies that the audio output of the video should be muted

poster="URL" -- specifies an image to be shown while the video is downloading, or until the user hits the play button

preload= "auto/metadata/none" -- specifies if and how the author thinks the video should be loaded when the page loads

src="URL" -- specifies the URL of the video file

Here is a screenshot from a sample Web page with video embedded in HTML5. enter image description here

Similarly, the tag can be used to embed audio/music on the Web page as follows:

  <source src="mymusic.ogg" type="audio/ogg" />

 <source src="mymusic.mp3" type="audio/mpeg" />

Upvotes: 1

Related Questions