web视频播放组件(easyplayer)和音频组件播放封装(vue-aplayer)

简介: web视频播放组件(easyplayer)和音频组件播放封装(vue-aplayer)使用只需要传相应的参数就可以使用,比较方便快捷。easyplay使用教程:https://blog.csdn.net/qq_44891434/article/details/118525941vue-aplayer使用教程:https://aplayer.netlify.app/docs/guide/options.html#autoplay

web视频播放组件(easyplayer)和音频组件播放封装(vue-aplayer)

使用只需要传相应的参数就可以使用,比较方便快捷。

easyplay使用教程:https://blog.csdn.net/qq_44891434/article/details/118525941

vue-aplayer使用教程:https://aplayer.netlify.app/docs/guide/options.html#autoplay


视频子组件编写

<template>
  <!-- 采用easyplayer.js -->
  <div :style="esayvideowidth">
    <easy-player :video-url="videoUrl" :poster="videoImg" :autoplay="false" />
  </div>
</template>
<script>
import EasyPlayer from '@easydarwin/easyplayer'
import 'videojs-contrib-hls'
export default {
  components: {
    // eslint-disable-next-line vue/no-unused-components
    EasyPlayer
  },
  // eslint-disable-next-line vue/require-prop-types
  props: ['esayurl', 'esayvideowidth'],
  data() {
    return {
      videoUrl: this.esayurl,
      videoImg: require('@/assets/3.jpg')
    }
  }
}
</script>

音频子组件封装

<template>
  <div :style="audiowidth">
    <!--music:当前播放的音乐。 list:播放列表 :showlrc:是否显示歌词-->
    <aplayer :music="videoUpload.music" />
  </div>
</template>
<script>
import aplayer from 'vue-aplayer'
export default {
  components: {
    aplayer
  },
  // eslint-disable-next-line vue/require-prop-types
  props: ['audiourl', 'audiowidth'],
  data() {
    return {
      videoUpload: {
        progress: false,
        progressPercent: 0,
        successPercent: 0,
        music: {
          title: '音乐播放器',
          author: ' ',
          // eslint-disable-next-line no-undef
          url: this.audiourl,
          pic: require('@/assets/music/audioBg.png')
          // lrc: '[00:00.00] (,,•́ . •̀,,) 抱歉,当前歌曲暂无歌词'
        }
      }
    }
  },
  mounted() {
  }
}
</script>
<style lang="scss" scoped>
</style>

父组件调用

<template>
  <!-- vue-video-player -->
  <div class="videoBox">
    <videoDisplay />
    <EsayVideo :esayurl="'/api/manager/file/materail/2021/0710/210710153208424119054.mp4'" :esayvideowidth="'width:800px;margin:1%;'" />
    <AudioPlay :audiourl="'/api/manager/file/materail/2021/0715/210715171331958135001.mp3'" :audiowidth="'width:300px;margin:1%;'" />
  </div>
</template>
<script>
import videoDisplay from '@/components/video/index'
import EsayVideo from '@/components/video/esayVideo'
import AudioPlay from './audio.vue'
// import { manager } from '@/api/base'
// const URL = process.env.VUE_APP_BASE_API + manager
export default {
  components: {
    // eslint-disable-next-line vue/no-unused-components
    videoDisplay,
    // eslint-disable-next-line vue/no-unused-components
    AudioPlay,
    // eslint-disable-next-line vue/no-unused-components
    EsayVideo
  },
  data() {
    return {
      // audiourl: URL + '/file/materail/2021/0715/210715171331958135001.mp3',
      // esayurl: URL + '/file/materail/2021/0710/210710153208424119054.mp4'
    }
  },
  mounted() {
    console.log(this.audiourl)
  }
}
</script>

效果图展示



相关文章
|
3月前
|
XML 编解码 前端开发
【web组件库系列】封装自己的字体图标库
【web组件库系列】封装自己的字体图标库
56 0
|
3月前
|
Java 应用服务中间件 容器
SpringBoot之Web原生组件注入
SpringBoot之Web原生组件注入
|
2月前
|
IDE API 开发工具
 鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Web组件
 鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Web组件
47 2
|
3月前
|
前端开发
【web组件库系列】纯CSS实现典型网页数据分页器
【web组件库系列】纯CSS实现典型网页数据分页器
46 0
|
3月前
【web server】HTTP协议如何解析or封装
【web server】HTTP协议如何解析or封装
|
3月前
|
存储 前端开发 Java
谈谈企业级 Web 应用里各种不同的 UI 组件设计思路
谈谈企业级 Web 应用里各种不同的 UI 组件设计思路
28 0
|
6月前
|
小程序 前端开发 开发者
微信小程序web-view上覆盖原生组件,解决cover-view点击事件无法触发问题
微信小程序web-view上覆盖原生组件,解决cover-view点击事件无法触发问题
153 0
|
6月前
|
Web App开发 编解码 前端开发
2023年WEB内嵌VLC直接播放RTSP视频流,无需服务器转码,支持硬件解码及高版本Chrome
2015年之前还可以用VLC原生播放器在Chrome、Firefox等浏览器中直接播放,延迟比较低,效果也还不错。可惜好景不长,从 2015年Chrome、Firefox等浏览器取消了对 NPAPI插件的支持,海康威视官方提供的 web3.0开发包也只能在低版本浏览器播放。
259 0
|
7月前
|
编解码 前端开发 UED
带你读《2022技术人的百宝黑皮书》——下一代响应式Web设计: 组件驱动式Web设计(1)
带你读《2022技术人的百宝黑皮书》——下一代响应式Web设计: 组件驱动式Web设计(1)
|
7月前
|
编解码 前端开发 JavaScript
带你读《2022技术人的百宝黑皮书》——下一代响应式Web设计: 组件驱动式Web设计(2)
带你读《2022技术人的百宝黑皮书》——下一代响应式Web设计: 组件驱动式Web设计(2)