RTSP Support in JavaFX Applications

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.

RTSP Support in JavaFX 1.2.x Release

Media Source

Windows Platform

Mac OS X

Linux Platform

Windows Server 2008 - Enterprise Edition, WMV Format playing not playing not playing
Windows Server 2008 - Enterprise Edition, MP3 Format playing not playing not playing
QuickTime Streaming Server/Darwin Streaming Server not playing playing not playing

playing - Functionality is supported not playing - 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.

Source Code
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 MediaPlayer object

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.