RTSP Support in JavaFX Applications
- Skill Level Advanced
- Supported Versions JavaFX 1.2
- Key Features JavaFX Media
- Last Updated February 2010
Real-Time Streaming Protocol (RTSP) support has been available in JavaFX SDK since the 1.2 version. This document clarifies which platforms support this functionality, and it provides basic recommendations for enabling streaming media in your application.
Real-Time Streaming Protocol is used to establish and control media sessions between endpoints. RTSP support was added to JavaFX SDK to enable communication with RTSP servers and to incorporate media from streaming media servers in JavaFX applications.
The following table shows the levels of RTSP support available on different platforms.
Media Source |
Windows Platform |
Mac OS X |
Linux Platform |
|
|---|---|---|---|---|
| Windows Server 2008 - Enterprise Edition, WMV Format | ||||
| Windows Server 2008 - Enterprise Edition, MP3 Format | ||||
| QuickTime Streaming Server/Darwin Streaming Server | ||||
- Functionality is supported
- Functionality is not supported
Live streaming media format is not supported on any of the platforms mentioned in the previous table.
To play back the streaming media files in your JavaFX application, specify the source URL as follows:
rtsp://host:port/mediafile
If the port number is omitted the default RTSP port 554 is used. The following code fragment constructs a simple embedded media player.
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.media.*;
Stage {
title: "Media test"
width: 250
height: 80
scene: Scene {
content: [
MediaView{
fitWidth: 200
preserveRatio: true
mediaPlayer: MediaPlayer{
autoPlay: true
media: Media{source: "rtsp://<media server>/myVideo.wmv"}
}
}
]
}
}
Tips
Use the bufferProgressTime instance variable of the MediaPlayer class for a bufferred media stream to obtain the following:
- Position of the current buffer
- Indication of how much media can be played without stalling the
MediaPlayerobject
Refer to the related How-To topics to learn more about media functionality in JavaFX SDK:
See also Incorporating Media Assets in JavaFX Applications for more information about how to control media playback.
Vyacheslav Baranov
Software Engineer, Sun Microsystems