【问题标题】:the currentTime() method of the videojs plugin doesn't workvideojs 插件的 currentTime() 方法不起作用
【发布时间】:2018-11-23 09:38:00
【问题描述】:

我正在使用 Videojs 插件作为视频播放器;我想要第二次重新启动播放器时;从我离开播放器之前的位置开始播放视频。

<div id="playerDiv">
      <video id="my_video_1" class="video-js vjs-default-skin"  controls preload="none">
            <source src="http://xxxxxx/stepupallin_en_fr_ts.mpg"  type='video/mpg' id="videosrc" />
      </video>
 </div>

播放我使用的视频:

$('#playerDiv').append('<video id="my_video_1" class="video-js vjs-default-skin"  controls preload="none" ><source src="http://xxxx/stepupallin_en_fr_ts.mpg" type="video/mpg"></video>');
    player = videojs("my_video_1"); 
    player.play();

离开我使用的播放器: whereYouAt = player.currentTime();//获取视频之前的位置 //别管它 var currentTime = localStorage.currentTime; localStorage.currentTime = whereYouAt; player.dispose();

当我第二次播放视频时:

player.currentTime(localStorage.currentTime); 

但我不知道为什么它不起作用

我也尝试过使用偏移,但它不起作用:

player.offset({
    start: localStorage.currentTime,
    end: localStorage.duration,
    restart_beginning: false 
});

我想要的只是从给定时间播放 videojs

【问题讨论】:

    标签: javascript jquery video.js


    【解决方案1】:

    player.currentTime(localStorage.currentTime); 无法工作,因为 localStorage 中的值存储为字符串。请改用player.currentTime(parseFloat(localStorage.currentTime));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多