Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8107191

MediaPlayer stop() function sometimes acts like pause()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • fx2.0
    • fx2.0
    • javafx
    • Windows Vista, JavaFX desktop b05

      The following code creates a MediaView and two buttons. Start the video clip by pressing Start, wait a few seconds then press Stop. According to the API, this resets the play head to the beginning of the media. However, if you now press Start, the video resumes from its current position. This behavior is NOT observed if the initialization of the startTime variable is commented out.

      As a separate point, the documentation for stop() say this:

      "Stops playing, resets to beginning of media, and resets the play count"

      It would be helpful it it stated what happens to the repeatCount (is is reset to the default?) and whether beginning of media means time 0 or startTime. If it means the latter, does a subsequent play restart from 0s or from startTime?

      --------------------------------------------------------------------------------
      package javafxmedia;

      import javafx.ext.swing.SwingButton;
      import javafx.scene.layout.HBox;
      import javafx.scene.media.Media;
      import javafx.scene.media.MediaPlayer;
      import javafx.scene.media.MediaView;
      import javafx.scene.Scene;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.scene.text.TextOrigin;
      import javafx.stage.Stage;

      var mediaURL = "http://sun.edgeboss.net/download/sun/media/1460825906/"
                     "1460825906_2956241001_big-buck-bunny-640x360.flv";

      var mediaView: MediaView;
      var mediaPlayer: MediaPlayer;
      Stage {
          title: "Media #2"
          resizable: false
          scene: Scene {
              width: 640
              height: 400
              content: [
                  mediaView = MediaView {
                      mediaPlayer:
                      mediaPlayer = MediaPlayer {
                          media: Media { source: mediaURL }
                          startTime: 35s
                          //stopTime: 50s
                      }
                  }
                  HBox {
                      spacing: 20
                      translateY: 360
                      content: [
                          SwingButton {
                              text: bind if (mediaPlayer.paused)
                                         "Start" else "Stop"
                              action: function() {
                                  if (mediaPlayer.paused) {
                                      mediaPlayer.play();
                                  } else {
                                      mediaPlayer.stop();
                                  }
                              }
                          }
                          SwingButton {
                              enabled: bind not mediaPlayer.paused
                              text: "Pause"
                              action: function() {
                                  mediaPlayer.pause();
                              }
                          }
                          Text {
                              font: Font { size: 16 }
                              textOrigin: TextOrigin.TOP
                              content: bind
                          "Cycle # {mediaPlayer.currentCount as Integer} "
                          "of {mediaPlayer.repeatCount as Integer}"
                          }
                      ]
                  }
              ]
          }
      }

            vbaranovsunw Vyacheslav Baranov (Inactive)
            ktopleyjfx Kim Topley (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: