y595705120 3 anni fa
parent
commit
7ad81ad458

+ 14 - 15
src/containers/center/play/components/media.vue

@@ -78,20 +78,20 @@
     },
     methods: {
       playerReadied(player) {
-        // if( !this.isReady ){
-          this.setposition( this.media.position||1 );
-        // }
-        let myPlayer = this.$refs.videoPlayer.player;
-        if( this.media.playRate>0 ){
-          let playRate = 1 + (+this.media.playRate/100);
-          myPlayer.playbackRate(playRate)
+        let that = this;
+        if( !this.isReady && this.media.position){
+          this.setposition( this.media.position );
+        }else if (!this.media.position ){
+          setTimeout( ()=>{
+            that.doPlay()
+          }, 2000 )
         }
         this.isReady = true
       },
       onPlayerTimeupdate( player ){
         let myPlayer = this.$refs.videoPlayer.player;
         let curTimes = player.cache_.currentTime;
-        if( curTimes > this.media.position+15 && !this.media.isFinish){
+        if( curTimes>30 && curTimes > this.media.position+15 && !this.media.isFinish){
           console.log("return", curTimes, this.media.position )
           player.currentTime( this.media.position );
           return;
@@ -99,14 +99,11 @@
       },
       setposition( position ) {
         if( position > this.media.duration) position = this.media.duration;
-        // if( !this.media.isFinish ){
-        //   let player = this.$refs.videoPlayer.player;
-        //   player.currentTime( position );
-        // }else{
-
-        // }
+        if( !this.media.isFinish ){
+          let player = this.$refs.videoPlayer.player;
+          player.currentTime( position );
+        }
         let player = this.$refs.videoPlayer.player;
-        player.currentTime( position );
         if( this.media.position >= this.media.duration-30 && !this.media.isFinish){
           this.tick( true )
         }
@@ -121,6 +118,7 @@
       doPause( ){
         let myPlayer = this.$refs.videoPlayer.player;
         myPlayer && myPlayer.pause()
+        console.log("doPause", myPlayer)
         this.onPlay = false
       },
       doPlay(){
@@ -173,6 +171,7 @@
         let curTimes = parseInt(myPlayer.currentTime());
         // 后退无心跳
         if( this.media.position > curTimes && !force ) return;
+        if( curTimes< 4) return;
 
         let isFinish = force?1:0
         if( curTimes >= media.duration ) isFinish = 1;

+ 1 - 0
src/containers/center/play/index.vue

@@ -363,6 +363,7 @@
           this.mediaType = 'hls';
           this.options.sources = [{src:this.mediaUrl,type: "application/x-mpegURL"}];
           this.options.playtimes = item.position;
+          this.options.autoplay = item.position>0;
           this.mediaDialog = true;
         });
       }