Best Practices and Troubleshooting


Consider the following best practices when developing JavaFX Media applications:

Issue: Media width, height, and duration are unavailable as soon as the source is set. If you expect to obtain the width, height, or duration of a streaming media as soon as the source is set, you might get the default value.

Workaround: Bind the width, height, or duration to the on replace trigger, and you get the correct value when the trigger's value is changed. For example:

Source Code
var  screenHeight = bind myMedia.height on replace { .. } 

Issue: Playback stops when the current time reaches the buffer head. When a streaming media is playing over a slow network, the playback pauses if it reaches the buffer head. It will not play again without user or program intervention, even though the buffer is progressing.

Workaround: Whether or not you set the player to the autoPlay mode, the workaround is to detect this pause when the current time is greater than zero and to programmatically enable playing after suitable buffer progress is detected. The application developer should evaluate how much buffer progress is needed.

Issue: Buffer progress is not updated on Windows if the player pauses when it reaches the buffer head. The application might display progress when playing a streaming media and pause because the current time reaches the buffer head. Even though the buffer is progressing inside the engine, the buffer progress is not updated.

Workaround: To enable displaying the buffer progress, fetch or pseudo-update metadata such as volume. This action triggers updating of the buffer progress variable.

Issue: On a very slow network with excessive network latency, playing even a streaming media supported by the platform throws an UnsupportedMediaException. On a very slow network with high latency, capturing enough of the stream to determine the type and its metadata might not always be possible. In such cases the engine times out and reports an UnsupportedMediaException.

Workaround: No real workaround exists for this issue. One solution is to play the media again so that the engine can gather enough data from the downloaded cache to enable further playback of the media.


Rate This Article
Discussion

We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of replies—your information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.

 

English
日本語
한국어
简体中文
русский
Português do Brasil