Hi, I have a project that I am working on. I have a video and I want it to be played within my java program with pause,start buttons etc, something like a media player. My question is, How do I go about doing this?, Is their some plug in that I need to use?. Please can someone help because I completely do not know where to start. This is the first time that I am doing something this big.
Embed Video Into Java Program
Page 1 of 14 Replies - 182 Views - Last Post: 04 February 2013 - 10:42 AM
Replies To: Embed Video Into Java Program
#2
Re: Embed Video Into Java Program
Posted 02 February 2013 - 08:03 AM
Check out the FMJ library
Or even better you can use JavaFX (the new replacement for Swing). It has built in support for media playback etc. Take a look at this.
Or even better you can use JavaFX (the new replacement for Swing). It has built in support for media playback etc. Take a look at this.
#3
Re: Embed Video Into Java Program
Posted 04 February 2013 - 10:27 AM
Thanks bro, one problem though, why does the video play like this:
This post has been edited by VIPERHlr: 04 February 2013 - 10:28 AM
#4
Re: Embed Video Into Java Program
Posted 04 February 2013 - 10:29 AM
Well I haven't got a clue as you haven't said how you're doing it.
Are you sure the video component fits the entire frame?
Are you sure the video component fits the entire frame?
#5
Re: Embed Video Into Java Program
Posted 04 February 2013 - 10:42 AM
Yes it does, heres my code:
package javafxapplication1;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
/**
*
* @author pc
*/
public class JavaFXApplication1 extends Application {
public static void main(String[]args)
{
launch(args);
}
@Override
public void start(final Stage stage)throws Exception
{
Group root = new Group();
Media media = new Media("file:/Users/pc/Desktop/Video.mp4");
final MediaPlayer player = new MediaPlayer(media);
MediaView view = new MediaView(player);
System.out.println("media.width: "+media.getWidth());
root.getChildren().add(view);
Scene scene = new Scene(root,400,400,Color.BLACK);
stage.setScene(scene);
stage.show();
player.play();
player.setOnReady(new Runnable()
{
@Override
public void run()
{
int w = player.getMedia().getWidth();
int h = player.getMedia().getHeight();
stage.setMinWidth(w);
stage.setMaxHeight(h);
}
});
}
}
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|