Created
January 16, 2010 15:01
-
-
Save bluepapa32/278850 to your computer and use it in GitHub Desktop.
How to use MediaPlayer
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
import javafx.scene.media.Media; | |
import javafx.scene.media.MediaPlayer; | |
import javafx.scene.media.MediaView; | |
import javafx.scene.paint.Color; | |
import javafx.scene.Scene; | |
import javafx.stage.Stage; | |
function run(args: String[]) { | |
var media = Media { | |
source: args[0] | |
}; | |
var player = MediaPlayer { | |
media: media | |
autoPlay: true | |
}; | |
var stage:Stage = Stage { | |
title: "Media Player"; | |
visible: true; | |
scene: Scene { | |
width: 640 | |
height: 320 | |
fill: Color.BLACK | |
content: [ | |
MediaView { | |
fitWidth: bind stage.scene.width | |
mediaPlayer: player | |
onMouseClicked: function(e) { | |
if (player.paused) { | |
player.play(); | |
} else { | |
player.pause(); | |
} | |
} | |
} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment