实时视频流index页全局刷新改为provide+inject组合局部刷新·

merge-requests/1/head
张鑫 5 years ago
parent 28ff32b80c
commit e21f2defbc

@ -154,7 +154,7 @@ export default {
// },
showModel(item){
console.log(11111)
this.player.destroy()
this.player= this.player.destroy()
clearInterval(this.timer)
console.log(item)
this.visible = true
@ -167,7 +167,7 @@ export default {
closeModel(visible,data){
this.visible = visible
this.modelData=data
},
}
},
components:{
Model

@ -73,30 +73,12 @@ export default {
// console.log(newVal)
if(newVal.id){
this.id = newVal.id
this.mdata = newVal
console.log(newVal)
// console.log('watch')
console.log('触发了watch重新赋值')
this.$nextTick(()=>{ //this.$nextTick
console.log(newVal.rtsp)
this.$api.httpApi.getChannel({
data:{
"sourceUrl":newVal.rtsp,
"paramBefore": "-y -i",
"paramBehind": "-f mpegts -codec:v mpeg1video -an -s 1707*960 -b:v 1000k -r 20 -bf 0 -codec:a mp2 -ar 44100 -ac 1 -b:a 128k"
}
}).then(res => {
console.log(res.data)
var url = 'ws://192.168.66.56:9007/api/lychee/stream/live/'+res.data.channel
var player = new JSMpeg.Player(url, {
canvas: document.querySelector('.video-canvas'),
audio: false,
pauseWhenHidden: false,
videoBufferSize: 8 * 1024 * 1024,
loop:false,
})
player.play()
}).catch(err => {
})
this.request(newVal)
})
}
@ -127,18 +109,59 @@ export default {
leftDownUrl:require('@/assets/left-down-icon.png'),
downUrl:require('@/assets/down-icon.png'),
rightDownUrl:require('@/assets/right-down-icon.png'),
player:'',
};
},
mounted() {
console.log('mounted执行了')
},
// provide(){ //
// return {
// reload: this.reloadModel
// }
// },
// inject: ['reload'],
// mounted() {
// console.log('mounted')
// },
methods: {
pauseEvent(e){
if(e.stopPropagation) e.stopPropagation();
if(e.preventDefault) e.preventDefault();
e.cancelBubble=true;
e.returnValue=false;
return false;
// reloadModel(){
// this.isRouter = false
// this.$nextTick( function () {
// this.isRouter = true
// console.log(this.mdata)
// this.player= this.player.destroy()
// this.request(this.mdata)
// })
// },
handleCancel() {
console.log('Clicked cancel button');
console.log(this.title);
location.reload();
const that=this
setTimeout(function () {
that.$emit('close',false,{})
},500)
},
request(data){
const that=this
this.$api.httpApi.getChannel({
data:{
"sourceUrl":data.rtsp,
"paramBefore": "-y -i",
"paramBehind": "-f mpegts -codec:v mpeg1video -an -s 1707*960 -b:v 1000k -r 20 -bf 0 -codec:a mp2 -ar 44100 -ac 1 -b:a 128k"
}
}).then(res => {
console.log(res.data)
var url = 'ws://192.168.66.56:9007/api/lychee/stream/live/'+res.data.channel
var player = new JSMpeg.Player(url, {
canvas: document.querySelector('.video-canvas'),
audio: false,
pauseWhenHidden: false,
videoBufferSize: 8 * 1024 * 1024,
loop:false,
})
return that.player=player
}).catch(err => {
})
},
zoomDecStart(){
console.log('变倍-按下')
@ -451,15 +474,6 @@ export default {
})
},
handleCancel() {
console.log('Clicked cancel button');
console.log(this.title);
location.reload();
setTimeout(function () {
this.$emit('close',false,{})
})
},
},
};
</script>

Loading…
Cancel
Save