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.

The nested structure of the media classes

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 fitWidth and fitHeight instance variable of the MediaView class to set the specific size of your video player. Then you can create several video thumbnails.
  • The MediaView class is a node and it inherits all the instance variables of the Node class 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

API Documentation

Last Updated: August 2010
[Return to How-To's Home]