Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-18055

Titanium VideoPlayer initialPlaybackTime setting does not work for second video in VideoPlayer

    Details

      Description

      Hello,

      I am using a playlist to simulate some kind of Live-TV.
      When the user initially opens the window and plays the video, the initialplaybacktime is set correctly of the video.

      Then if the user stops the video by clicking on it (Looks like it's being paused but actually it's stopped ($.video.stop()) to reload the playlist and get the live elapsed time) and then clicks it again.

      When the user clicks it after it's stopped, the playlist is reloaded and the current video is set as url and it's elapsed time is set with setInitialPlaybackTime().

      But this doesn't work, and it results into a 'NaN' if I try to retrieve it the playback has started the second time, so not the initial time the user opens the window.

      Testcase

      var win = Ti.UI.createWindow({
          exitOnClose: true,
          layout: 'vertical'
      });
       
      var url = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4";
       
      var videoPlayer = Ti.Media.createVideoPlayer({
          top:                        0,
          scalingMode:                Ti.Media.VIDEO_SCALING_ASPECT_FIT,
          autoplay:                   false,
          width:                      Ti.Platform.displayCaps.platformWidth,
          height:                     Ti.Platform.displayCaps.platformWidth * (9/16), // 16:9 ratio on the screen
          fullscreen:                 false,
          mediaControlStyle:          Ti.Media.VIDEO_CONTROL_NONE
      });
      videoPlayer.addEventListener('playbackstate', function(e) {
         if(e.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING) {
             btn.title = "Stop";
             Ti.API.info("Initial playback videoPlayer on state change: "+this.getInitialPlaybackTime());
             Ti.API.info("Current playback videoPlayer on state change: "+this.getCurrentPlaybackTime());
         } else if(e.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_STOPPED) {
             btn.title = "Play";
         }
      });
      win.add(videoPlayer);
       
      var btn = Ti.UI.createButton({
          top: 20,
          width: "60%",
          height: 40,
          title: "Play"
      });
      btn.addEventListener("click", function() {
          if(videoPlayer.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING) {
              videoPlayer.stop();
              videoPlayer.url = "";
          } else {
              var initialPlayback = Math.floor((Math.random() * 10000) + 1000); // random initial
              Ti.API.info("Initial playback: "+initialPlayback);
              Ti.API.info("Initial playback videoPlayer on click: "+videoPlayer.getInitialPlaybackTime());
              Ti.API.info("Current playback videoPlayer on click: "+videoPlayer.getCurrentPlaybackTime());
              videoPlayer.setInitialPlaybackTime(initialPlayback);
              videoPlayer.setUrl(url);
              videoPlayer.play();
          }
      });
      win.add(btn);
      win.open();
      

      This code exactly shows in the logs that it does not work.

      Regards,
      Patrick van Vuuren

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Serfenia Patrick van Vuuren
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-19384
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration