video-format.uvue 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<template>
  <scroll-view>
    <page-head :title="title"></page-head>
    <view class="uni-padding-wrap uni-common-mt">
      <view class="uni-title">
        <text class="uni-title-text">支持的视频格式示例</text>
      </view>
      <view v-for="(item,index) in supportFormats" :key="index">
        <text class="uni-subtitle-text">{{item.format}}</text>
        <video :id="'video-' + item.format" class="video" :src="item.src" :controls="true" :direction="-90"
          @error="onError"></video>
      </view>
      <view class="uni-title">
        <text class="uni-title-text">暂不支持的格式</text>
      </view>
      <view v-for="(item,index) in notSupportFormats" :key="index">
        <text class="uni-subtitle-text">{{item.format}}</text>
        <video :id="'video-' + item.format" class="video" :src="item.src" :controls="true" :direction="-90"></video>
      </view>
    </view>
  </scroll-view>
</template>

<script>
  export default {
    data() {
      return {
        title: 'video-format',
        supportFormats: [
          {
            format: 'mp4',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4'
          },
          {
            format: 'm4v',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.m4v'
          },
          {
            format: 'mov',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mov'
          },
          {
            format: 'webm',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.webm'
          },
          {
            format: '3gp',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.3gp'
          },
          {
            format: 'flv',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.flv'
          },
          {
            format: 'm3u8',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.m3u8'
          },
          {
            format: '本地m3u8',
            src: '/static/test-video/2minute-demo.m3u8'
          }
        ] as Array<VideoFormat>,
        notSupportFormats: [
          {
            format: 'ogg',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.ogg'
          },
          {
            format: 'avi',
            src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.avi'
          }
        ] as Array<VideoFormat>,
        isError: false
      }
    },
    methods: {
      onError: function (_ : VideoErrorEvent) {
        this.isError = true;
      }
    }
  }

  type VideoFormat = {
    format : string
    src : string
  }
</script>

<style>
  .video {
    height: 400rpx;
  }
</style>