How-To's > How do I add a video player?
You can easily create a simple video panel by using the MediaView and MediaPlayer classes as shown here.

def media = Media {source: "http://<myMediaServer>/<myVideoFile>"};
Stage {
title: "Embedded Player"
scene: Scene {
width: 200
height: 100
content: MediaView{
mediaPlayer: MediaPlayer {
media: media
}
}
}
}
Tips
- Use the
fitWidthandfitHeightinstance variable of theMediaViewclass to set the specific size of your video player. Then you can create several video thumbnails. - The
MediaViewclass is a node and it inherits all the instance variables of theNodeclass to apply transformations, effects, and animation. - Start with a simple embedded media panel and enhance your application so that it can control playback, access volume and balance controls, and retrieve information about the media. See also How do I control playback from code?
Examples
- Dragging an MP3 Player Applet to the Desktop
This sample shows how to create a draggable player that users can save on the desktop for later use. - Playing Video on the Sides of a Rotating Cube
This sample shows how to play video on the sides of a rotating cube.
API Documentation
Last Updated: August 2010
[Return to How-To's Home]