video-view.nvue 1.6 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
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
<template>
  <view class="content">
    <video-view id="video" ref="video" class="video" :src="src">
    </video-view>
    <button class="button" @click="play" type="primary">播放</button>
    <text class="tiptitle">注意:</text>
    <view class="tips">
      <text class="tip">uts组件插件video-view需要使用自定义基座才能生效!</text>
      <text class="tip">暂时仅支持uni-app x项目!</text>
      <text class="tip">暂时仅支持Android平台!</text>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        src: 'https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20181126-lite.m4v'
      }
    },
    methods: {
      play() {
        //uni-app 项目 nvue 页面中的调用方式
        this.$refs['video'].play();
        //uni-app x 项目 uvue 页面中的调用方式(以下方式二选一)
        // (this.$refs['video'] as VideoViewElement).play();
        // (uni.getElementById('video') as VideoViewElement).play();
      }
    }
  }
</script>

<style>
  .content {
    display: flex;
    flex: 1;
    align-items: center;
  }

  .video {
    width: 750rpx;
    height: 400rpx;
  }

  .button {
    width: 640rpx;
    margin: 10px;
  }

  .tiptitle {
    margin-top: 20px;
    font-size: 18px;
    color: darkred;
  }

  .tips {
    justify-content: flex-start;
    margin: 0px 20px;
  }

  .tip {
    color: darkred;
  }
</style>