123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <template>
- <view>
- <web-view src="@/hybrid/html/local.html"></web-view>
- <!-- <view class="uni-padding-wrap uni-common-mt">-->
- <!-- <view>-->
- <!-- <video id="myVideo" src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"-->
- <!-- @error="videoErrorCallback" :danmu-list="danmuList" enable-danmu danmu-btn controls></video>-->
- <!-- </view>-->
- <!-- <!– #ifndef MP-ALIPAY –>-->
- <!-- <view class="uni-list uni-common-mt">-->
- <!-- <view class="uni-list-cell">-->
- <!-- <view>-->
- <!-- <view class="uni-label">弹幕内容</view>-->
- <!-- </view>-->
- <!-- <view class="uni-list-cell-db">-->
- <!-- <input v-model="danmuValue" class="uni-input" type="text" placeholder="在此处输入弹幕内容" />-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- <view class="uni-btn-v">-->
- <!-- <button @click="sendDanmu" class="page-body-button">发送弹幕</button>-->
- <!-- </view>-->
- <!-- <!– #endif –>-->
- <!-- </view>-->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- src: '',
- danmuList: [{
- text: '第 1s 出现的弹幕',
- color: '#ff0000',
- time: 1
- },
- {
- text: '第 3s 出现的弹幕',
- color: '#ff00ff',
- time: 3
- }
- ],
- danmuValue: ''
- }
- },
- onReady: function(res) {
- // #ifndef MP-ALIPAY
- this.videoContext = uni.createVideoContext('myVideo')
- // #endif
- },
- methods: {
- sendDanmu: function() {
- this.videoContext.sendDanmu({
- text: this.danmuValue,
- color: this.getRandomColor()
- });
- this.danmuValue = '';
- },
- videoErrorCallback: function(e) {
- uni.showModal({
- content: e.target.errMsg,
- showCancel: false
- })
- },
- getRandomColor: function() {
- const rgb = []
- for (let i = 0; i < 3; ++i) {
- let color = Math.floor(Math.random() * 256).toString(16)
- color = color.length == 1 ? '0' + color : color
- rgb.push(color)
- }
- return '#' + rgb.join('')
- }
- }
- }
- </script>
- <!--<template>-->
- <!-- <view class="content">-->
- <!-- <view class="player-content">-->
- <!-- <live-player id="livePlayer" class="live-player" catchtouchmove :src="currentUrl" autoplay-->
- <!-- background-mute sound-mode="speaker" mode='RTC' @statechange="statechange" @click="handleControlbar">-->
- <!-- <view class="player-tool" :style="{bottom:(showControlbar?'0':'-60rpx')}">-->
- <!-- <view class="tools">-->
- <!-- <view class="full-screen" @tap.stop="handleFullScreen()">-->
- <!-- <text class="iconfont" v-if="!fullScreenFlag">进入全屏</text>-->
- <!-- <text class="iconfont" v-else></text>-->
- <!-- </view>-->
- <!-- <view class="cruise" @tap.stop="handleCruise()" v-if="streamIndex == 2">-->
- <!-- <text class="iconfont">退出全屏</text>-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- </live-player>-->
- <!-- </view>-->
- <!-- </view>-->
- <!--</template>-->
- <!--<script>-->
- <!--export default {-->
- <!-- data() {-->
- <!-- return {-->
- <!-- isPlaySource: false, //是否有播放源-->
- <!-- isVideoLive: false, //是否是直播-->
- <!-- isAutoplay: true, //是否自动播放-->
- <!-- videoMsg: '', //video消息-->
- <!-- currentUrl: '', //播放路径-->
- <!-- showControlbar: true,-->
- <!-- timer:null,-->
- <!-- }-->
- <!-- },-->
- <!-- watch: {-->
- <!-- showControlbar(val, oldVal) {-->
- <!-- if(val){-->
- <!-- this.timer = setTimeout(()=>{-->
- <!-- this.showControlbar = false-->
- <!-- },5000)-->
- <!-- }else{-->
- <!-- clearTimeout(this.timer);-->
- <!-- }-->
- <!-- }-->
- <!-- },-->
- <!-- onLoad() {-->
- <!-- this.playerCtx = uni.createLivePlayerContext('livePlayer');-->
- <!-- },-->
- <!-- created() {-->
- <!-- this.getLiveList() //视频流列表-->
- <!-- setTimeout(()=>{-->
- <!-- this.showControlbar = false-->
- <!-- },10000)-->
- <!-- },-->
- <!-- methods: {-->
- <!-- handleControlbar() {-->
- <!-- this.showControlbar = !this.showControlbar-->
- <!-- },-->
- <!-- getLiveList() {-->
- <!-- this.$api.livePage.getLiveList().then(res => {-->
- <!-- //业务逻辑-->
- <!-- }).catch(err => {-->
- <!-- console.log('err');-->
- <!-- });-->
- <!-- },-->
- <!-- // 巡航-->
- <!-- handleCruise() {-->
- <!-- // #ifdef MP-WEIXIN-->
- <!-- uni.vibrateShort();-->
- <!-- // #endif-->
- <!-- },-->
- <!-- //全屏功能的实现-->
- <!-- handleFullScreen() {-->
- <!-- var that = this-->
- <!-- if (!that.fullScreenFlag) {-->
- <!-- //全屏-->
- <!-- that.playerCtx.requestFullScreen({-->
- <!-- success: res => {-->
- <!-- that.fullScreenFlag = true-->
- <!-- console.log('我要执行了');-->
- <!-- },-->
- <!-- fail: res => {-->
- <!-- console.log('fullscreen fail');-->
- <!-- },-->
- <!-- direction: 90-->
- <!-- });-->
- <!-- } else {-->
- <!-- //缩小-->
- <!-- that.playerCtx.exitFullScreen({-->
- <!-- success: res => {-->
- <!-- that.fullScreenFlag = false-->
- <!-- console.log('我要执行了');-->
- <!-- },-->
- <!-- fail: res => {-->
- <!-- console.log('exit fullscreen success');-->
- <!-- }-->
- <!-- });-->
- <!-- }-->
- <!-- },-->
- <!-- }-->
- <!--}-->
- <!--</script>-->
- <!--<style lang="scss" scoped>-->
- <!--.content {-->
- <!-- width: 100%;-->
- <!-- height: 100%;-->
- <!-- display: flex;-->
- <!-- flex-direction: column;-->
- <!-- .player-content {-->
- <!-- position: relative;-->
- <!-- width: 100%;-->
- <!-- height: 450rpx;-->
- <!-- display: flex;-->
- <!-- background-size: 100% 100%;-->
- <!-- .live-player {-->
- <!-- width: 100%;-->
- <!-- height: 100%;-->
- <!-- position: relative;-->
- <!-- }-->
- <!-- }-->
- <!--}-->
- <!--//播放器弹出工具-->
- <!--.player-tool {-->
- <!-- width: 100%;-->
- <!-- height: 60rpx;-->
- <!-- background-image: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);-->
- <!-- display: flex;-->
- <!-- align-items: center;-->
- <!-- justify-content: space-between;-->
- <!-- position: absolute;-->
- <!-- left: 0;-->
- <!-- padding: 0 45rpx;-->
- <!-- transition: all 0.3s;-->
- <!-- .tools {-->
- <!-- height: 100%;-->
- <!-- width: auto;-->
- <!-- display: flex;-->
- <!-- align-items: center;-->
- <!-- .full-screen {-->
- <!-- height: 100%;-->
- <!-- display: flex;-->
- <!-- align-items: center;-->
- <!-- justify-content: center;-->
- <!-- .iconfont {-->
- <!-- color: #fff;-->
- <!-- font-weight: bold;-->
- <!-- }-->
- <!-- }-->
- <!-- .cruise {-->
- <!-- display: flex;-->
- <!-- align-items: center;-->
- <!-- justify-content: center;-->
- <!-- margin-left: 25rpx;-->
- <!-- .iconfont {-->
- <!-- color: #E45A3E;-->
- <!-- font-size: 45rpx;-->
- <!-- }-->
- <!-- }-->
- <!-- }-->
- <!--}-->
- <!--</style>-->
- <!--<!–<template>–>-->
- <!--<!– <view>–>-->
- <!--<!–<!– <my-grid></my-grid>–>–>-->
- <!--<!– <video–>-->
- <!--<!– id="myVideo"–>-->
- <!--<!– :src="src"–>-->
- <!--<!– :controls="controls"–>-->
- <!--<!– :autoplay="autoplay"–>-->
- <!--<!– style="width: 100%; height: 300px;"–>-->
- <!--<!– ></video>–>-->
- <!--<!– </view>–>-->
- <!--<!–</template>–>-->
- <!--<!–<script>–>-->
- <!--<!– export default {–>-->
- <!--<!– data() {–>-->
- <!--<!– return {–>-->
- <!--<!– src: '../../static/vedio/1.mp4', // 视频地址–>-->
- <!--<!– controls: true, // 是否显示控制条–>-->
- <!--<!– autoplay: false, // 是否自动播放–>-->
- <!--<!– };–>-->
- <!--<!– }–>-->
- <!--<!– }–>-->
- <!--<!–</script>–>-->
- <!--<!–<style lang="scss">–>-->
- <!--<!–</style>–>-->
|