JDK-8259356 : MediaPlayer's seek freezes video
  • Type: Bug
  • Component: javafx
  • Sub-Component: media
  • Affected Version: 8u191,openjfx15,openjfx16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x,windows
  • CPU: generic
  • Submitted: 2021-01-07
  • Updated: 2021-05-25
  • Resolved: 2021-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u301Fixed openjfx11.0.12Fixed
Related Reports
Duplicate :  
Relates :  
Description
Some videos (of not uncommon conversion/format) will freeze if you seek too soon after they are loaded. The audio keeps playing in the background.

The issue is reproducible with both local and remote video files.

This is a regression as the problem occurs only starting JavaFX 14 (for Windows) and 15 (for MacOS). 

N.B. On MacOS until JavaFX 14, the video plays after the long start up delay (JDK-8241629).

SSCCE with remote Video URLs:

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.layout.FlowPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.stage.Stage;
import javafx.util.Duration;

public class VideoSeekIssue extends Application {

    @Override
    public void start(Stage primaryStage) {
        final Media bad = new Media("https://sideline.s3.amazonaws.com/tmp-delete/2020_11_20_Onnered_Savehof.mp4");
        final Media good = new Media("https://sideline.s3.amazonaws.com/faq/10-minutes-of-typical-video.mp4");

        final Dialog dialog = new Dialog();
        dialog.setTitle("Bad video will work if you do not seek soon");

        dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);

        Button btnOpenSeek = new Button("Open+Seek (bad vid)");
        btnOpenSeek.onActionProperty().setValue(actionEvent -> open(bad, false));

        Button btnOpenSeekLater = new Button("Open+Seek later (bad vid)");
        btnOpenSeekLater.onActionProperty().setValue(actionEvent -> open(bad, true));

        Button btnOpenSeekGood = new Button("Open+Seek (good vid)");
        btnOpenSeekGood.onActionProperty().setValue(actionEvent -> open(good, false));

        dialog.getDialogPane().setContent(new FlowPane(
                btnOpenSeek, btnOpenSeekLater, btnOpenSeekGood));
        dialog.show();
    }

    private static void open(Media media, boolean seekLater) {
        final MediaPlayer player = new MediaPlayer(media);

        MediaView mediaView = new MediaView(player);

        Group root = new Group(mediaView);
        Scene scene = new Scene(root, 1280, 720);

        Stage stage = new Stage();
        stage.setTitle("Media Player with " + System.getProperty("jfxmedia.platform") + " playing " + media.getSource());
        stage.setScene(scene);
        stage.show();

        player.play();

        if (seekLater) {
            new Thread(() -> {
                try { Thread.sleep(10000); } catch (Exception e){}
                Platform.runLater(() -> player.seek(Duration.seconds(400)));
            }).start();
        } else {
            player.setOnPlaying(() -> player.seek(Duration.seconds(400)));
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Comments
Changeset: a6835580 Author: Alexander Matveev <almatvee@openjdk.org> Date: 2021-04-19 18:04:11 +0000 URL: https://git.openjdk.java.net/jfx/commit/a6835580
19-04-2021

This is regression (introduced) by JDK-8199527.
17-04-2021

On MacOS, This behavior is shown after the fix for JDK-8241629: [macos10.15] Long startup delay playing media over https on Catalina Since this change, we link with our own ffi lib instead of the one provided by the system.
13-04-2021

It may or may not be relevant, but the following third-party upgrade was done in JavaFX 14: JDK-8230610: Upgrade GStreamer to version 1.16.1 JDK-8230609: Upgrade glib to version 2.62.2
07-01-2021