y595705120 3 years ago
parent
commit
b40a058375

+ 10 - 7
src/containers/center/play/components/media.vue

@@ -78,9 +78,9 @@
     },
     methods: {
       playerReadied(player) {
-        if( !this.isReady ){
-          this.setposition( this.media.position );
-        }
+        // 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);
@@ -99,11 +99,14 @@
       },
       setposition( position ) {
         if( position > this.media.duration) position = this.media.duration;
-        if( !this.media.isFinish ){
-          let player = this.$refs.videoPlayer.player;
-          player.currentTime( position );
-        }
+        // if( !this.media.isFinish ){
+        //   let player = this.$refs.videoPlayer.player;
+        //   player.currentTime( position );
+        // }else{
 
+        // }
+        let player = this.$refs.videoPlayer.player;
+        player.currentTime( position );
         if( this.media.position >= this.media.duration-30 && !this.media.isFinish){
           this.tick( true )
         }

+ 20 - 2
src/containers/center/play/index.vue

@@ -141,6 +141,12 @@
           @close="mediaDialog=false"
           @update="update">
         </Media>
+        <span slot="footer" class="dialog-footer">
+          <el-select placeholder="流畅" v-model="mediaType" style="width: 80px;">
+            <el-option label="流畅" value="ld"></el-option>
+            <el-option label="标清" value="hls"></el-option>
+          </el-select>
+        </span>
 
     </el-dialog>
 
@@ -173,6 +179,8 @@
         courseId: 0,
         show:1,
         mediaDialog: false,
+        mediaType:'hls',
+        mediaUrl:'',
         editRzcode: false,
         info: {score:0, percent:0},
         tpl:{},
@@ -212,6 +220,15 @@
     watch:{
       show(val){
         this.updateShowList()
+      },
+      mediaType(val){
+        let mediaUrl = this.mediaUrl;
+        if( val == 'ld'){
+          mediaUrl = mediaUrl.replace('/hls/', '/ld/');
+        }
+        this.options.sources = [{src:mediaUrl,type: "application/x-mpegURL"}];
+        this.options.playtimes = this.media.position||0;
+        this.mediaDialog = true;
       }
     },
     filters:{
@@ -342,8 +359,9 @@
         this.media = item;
         this.media.index = index
         httpServer('course.GetMedia', {id:item.id}).then( ({data, code}) => {
-          item.url = data
-          this.options.sources = [{src:item.url}];
+          this.mediaUrl = data
+          this.mediaType = 'hls';
+          this.options.sources = [{src:this.mediaUrl,type: "application/x-mpegURL"}];
           this.options.playtimes = item.position;
           this.mediaDialog = true;
         });