<web-view :src="webViewUrl" @message="handleMessage"></web-view> // 父页面
<body>
<div id="player-con"></div>
</body>
var skinLayout = [{
"name": "bigPlayButton",
"align": "cc",
"x": 0,
"y": 0
},
{
"name": "H5Loading",
"align": "cc"
},
{
"name": "errorDisplay",
"align": "tlabs",
"x": 0,
"y": 0
},
{
"name": "infoDisplay"
},
{
"name": "tooltip",
"align": "blabs",
"x": 0,
"y": 56
},
{
"name": "thumbnail"
},
{
"name": "controlBar",
"align": "blabs",
"x": 0,
"y": 0,
"children": [{
"name": "progress",
"align": "blabs",
"x": 0,
"y": 44
},
{
"name": "playButton",
"align": "tl",
"x": 15,
"y": 12
},
{
"name": "timeDisplay",
"align": "tl",
"x": 10,
"y": 7
}, {
"name": "fullScreenButton",
"align": "tr",
"x": 10,
"y": 12
}
]
}
]
function initPlayer() {
playerInit = new Aliplayer({
id: "player-con",
source: source,
width: "100%",
height: "200px",
autoplay: false,
preload: false,
skinLayout: skinLayout,
}, (player) => {
player.on('ready', () => {
})
player.on('play', () => {
console.log('play')
status = 'play'
time = player.getCurrentTime()
uni.postMessage({
data: {
status: status,
time: time
}
});
timer = setInterval(() => {
console.log('定时器保存')
time = player.getCurrentTime()
uni.postMessage({
data: {
status: 'timing',
time: time
}
});
}, intervalTime)
})
player.on('pause', () => {
status = 'pause'
time = player.getCurrentTime()
uni.postMessage({
data: {
status: status,
time: time
}
});
clearInterval(timer)
})
player.on('playing', () => {
})
player.on('timeupdate', () => {
status = 'timeupdate'
time = player.getCurrentTime()
uni.postMessage({
data: {
status: status,
time: time
}
});
})
player.on('end', () => {
status = 'end'
time = player.getCurrentTime()
uni.postMessage({
data: {
status: status,
time: time
}
});
clearInterval(timer)
})
player.on('error', (e) => {
})
player.on('requestFullScreen', (e) => {
})
player.on('cancelFullScreen', (e) => {
})
});
}
0 个回复