vue + videojs 处理 m3u8 的坑

栏目: JavaScript · 发布时间: 4年前

内容简介:坑后面再说,先让m3u8运行起来,<link href="<script src="

vue + videojs 处理 m3u8 的坑:

坑后面再说,先让m3u8运行起来,

第一步:首先vue的index.html 引入

<link href=" http://cdn.bootcss.com/video.... ; rel="stylesheet" />

<script src=" http://cdn.bootcss.com/video.... ;></script>

<script src=" http://cdn.bootcss.com/videoj... ;></script>

这3个东西,我觉得这几个很重要!

第二步:然后在xxx.vue使用:

<video

id="hls-video"

    width="1024"

    height="576"

    class="video-js vjs-default-skin"

    playsinline

    webkit-playsinline

    controls

    preload="auto"

    x-webkit-airplay="true"

    x5-video-player-fullscreen="true"

    x5-video-player-typ="h5"

  >

    <source

      src="your addr"

      type="application/x-mpegURL"

    >

  </video>

第三步:js中的mouted()实例化:

var player;

player = videojs('hls-video');

补充:在methods中可以用:player.play()播放;player.pause()暂停。

坑来了!:

如果你第一次渲染,完全没问题,如果从这个页面跳spa到别的页面,再跳回来,bug出现了!

为什么会有红字error?我做错了什么?

因为你没有销毁这个东西!

在本页面xxx.vue 中加上:

beforeDestroy: function () {

player.dispose();

},

完美解决!这个东西真的太坑了!

感谢大家的支持!!谢谢


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Coming of Age in Second Life

Coming of Age in Second Life

Tom Boellstorff / Princeton University Press / 2008-04-21 / USD 29.95

The gap between the virtual and the physical, and its effect on the ideas of personhood and relationships, is the most interesting aspect of Boellstorff's analysis... Boellstorff's portrayal of a virt......一起来看看 《Coming of Age in Second Life》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具