130 lines
2.6 KiB
Plaintext
130 lines
2.6 KiB
Plaintext
<template>
|
|
<div>
|
|
<view>
|
|
<view class="title">播放进度</view>
|
|
<text style="color: #576B95;">{{text}}</text>
|
|
</view>
|
|
<button @click="startSearch"> 搜索投屏设备 </button>
|
|
<button @click="startPush"> 开始投屏 </button>
|
|
<button @click="startPushed"> 开始投屏2 </button>
|
|
<button @click="stopPush"> 停止投屏 </button>
|
|
<button @click="pausePush"> 暂停 </button>
|
|
<button @click="resumePush"> 播放 </button>
|
|
<button @click="seekTo"> 快进10秒 </button>
|
|
<button @click="getVolume"> 获取电视声音 </button>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
const ox = uni.requireNativePlugin('Jiang-OxePlayer');
|
|
var device;
|
|
var p = 0;
|
|
export default {
|
|
data() {
|
|
return {
|
|
text: '0'
|
|
}
|
|
},
|
|
onReady() {
|
|
console.log('44444444');
|
|
ox.initDlna();
|
|
const that = this;
|
|
var globalEvent = weex.requireModule('globalEvent');
|
|
globalEvent.addEventListener('dlnaCallback', function(e) {
|
|
console.log(e);
|
|
let code = e.code;
|
|
if (code == 10) {
|
|
let v = e.volume;
|
|
ox.setVolume({
|
|
volume: v
|
|
});
|
|
}else if(code == 0){
|
|
let t = e.position
|
|
that.text = t;
|
|
p = t;
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
|
|
startSearch: function() {
|
|
ox.startSearch(result => {
|
|
console.log(result);
|
|
if (result.code == 0) {
|
|
var ds = result.devices;
|
|
device = ds[0];
|
|
}
|
|
|
|
});
|
|
},
|
|
startPush: function() {
|
|
ox.stopPush();
|
|
setTimeout(function() {
|
|
ox.startPush({
|
|
url: 'https://yixuancdn.bangju.com/%E6%8E%8C%E6%8F%A1%E5%81%A5%E5%BA%B7%E7%9A%84%E9%87%91%E9%92%A5%E5%8C%99%20%5BAVC%20720p%5D_batch_batch.mp4',
|
|
device: device
|
|
});
|
|
}, 1000);
|
|
|
|
},
|
|
startPushed: function() {
|
|
ox.stopPush();
|
|
setTimeout(function() {
|
|
ox.startPush({
|
|
url: 'https://yixuancdn.bangju.com/%E8%B6%B3%E9%83%A8%E5%8F%8D%E5%B0%84%E7%96%97%E6%B3%95%E7%AC%AC%E4%B8%80%E7%BB%84%E3%80%8B%20%5BAVC%20720p%5D~1.mp4',
|
|
device: device
|
|
});
|
|
}, 1000);
|
|
|
|
},
|
|
stopPush: function() {
|
|
ox.stopPush();
|
|
},
|
|
pausePush: function() {
|
|
ox.pause();
|
|
},
|
|
resumePush: function() {
|
|
ox.resume();
|
|
},
|
|
seekTo: function() {
|
|
ox.seek({position:p+10});
|
|
},
|
|
getVolume: function() {
|
|
ox.getVolume(result => {
|
|
console.log(result);
|
|
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.card {
|
|
width: 750rpx;
|
|
margin-top: 60rpx;
|
|
flex-direction: row;
|
|
flex-wrap: wrap;
|
|
background-color: #C0C0C0;
|
|
}
|
|
|
|
.box {
|
|
width: 185rpx;
|
|
height: 185rpx;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.row-box {
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
margin: 10rpx;
|
|
background-color: #00000000;
|
|
}
|
|
|
|
.uni-form-item .title {
|
|
padding: 20rpx 20;
|
|
}
|
|
</style>
|