forked from bduong/super-kids
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'javafx' into xuggler
- Loading branch information
Showing
8 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
GUI/src/main/java/superkidsapplication/panels/VideoPlayerPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package superkidsapplication.panels; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.Color; | ||
import javafx.application.Platform; | ||
import javax.swing.JPanel; | ||
import javafx.scene.media.Media; | ||
import javafx.scene.media.MediaPlayer; | ||
import javafx.scene.media.MediaView; | ||
import javafx.scene.Group; | ||
import javafx.scene.Scene; | ||
import javafx.embed.swing.JFXPanel; | ||
import javax.swing.SwingUtilities; | ||
|
||
/** | ||
* | ||
* @author Heng | ||
*/ | ||
public class VideoPlayerPanel extends JPanel{ | ||
|
||
private String filepath=null; | ||
private Media media=null; | ||
private MediaPlayer mediaplayer=null; | ||
private MediaView mediaview=null; | ||
private Group root=null; | ||
private Scene scene = null; | ||
private JFXPanel jfxpanel=new JFXPanel(); | ||
|
||
public VideoPlayerPanel(String str){ | ||
//TODO constructor | ||
this.filepath=str; | ||
//this.setBackground(Color.red); | ||
this.setSize(640, 360); | ||
initAndShowGUI(); | ||
} | ||
|
||
private void initAndShowGUI(){ | ||
|
||
|
||
|
||
this.add(jfxpanel,BorderLayout.CENTER); | ||
this.setVisible(true); | ||
|
||
Platform.runLater(new Runnable(){ | ||
@Override | ||
public void run(){ | ||
initFX(jfxpanel); | ||
} | ||
}); | ||
} | ||
|
||
private void initFX(JFXPanel jfxpenal){ | ||
root=new Group(); | ||
scene=new Scene(root,640,360); | ||
media=new Media(filepath); | ||
mediaplayer=new MediaPlayer(media); | ||
mediaview=new MediaView(mediaplayer); | ||
mediaplayer.setAutoPlay(true); | ||
root.getChildren().add(mediaview); | ||
jfxpanel.setScene(scene); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters