@shijiu/jsview-vue 2.0.1021 → 2.0.1045-next-vue.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +26 -1
- package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +120 -133
- package/utils/JsViewPlugin/JsvPlayer/GetVersion.js +1 -1
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayerBrowser.vue +370 -41
- package/utils/JsViewVueTools/JsvHashHistory.js +2 -1
- package/utils/JsViewVueWidget/JsvSystemAudio.vue +82 -40
package/package.json
CHANGED
|
@@ -10,6 +10,11 @@ import Events from "./Events.js"
|
|
|
10
10
|
|
|
11
11
|
const TAG = "JsvAudio";
|
|
12
12
|
|
|
13
|
+
let keyToken = 0;
|
|
14
|
+
const getKeyToken = () => {
|
|
15
|
+
return ++keyToken;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
class AudioManager {
|
|
14
19
|
constructor() {
|
|
15
20
|
this.audioMap = {};
|
|
@@ -63,6 +68,8 @@ class AudioProxy {
|
|
|
63
68
|
this._created = false;
|
|
64
69
|
this._eventListener = {};
|
|
65
70
|
this._propCache = {};
|
|
71
|
+
this._onVisibilityChange = this.onVisibilityChange.bind(this);
|
|
72
|
+
window.JsView?.onVisibilityChange(this._onVisibilityChange);
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
/** 初始化函数, 外部不应该调用 */
|
|
@@ -298,8 +305,26 @@ class AudioProxy {
|
|
|
298
305
|
window.JMD.unsubscribe(this._playerId, this._onEvent);
|
|
299
306
|
JsvAudioBridgeProxy.ReleasePlayer(this._playerId);
|
|
300
307
|
this._audioManager.releaseAudio(this._playerId);
|
|
308
|
+
window.JsView?.removeEventCallback(this._onVisibilityChange);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
onVisibilityChange(state) {
|
|
313
|
+
console.log(TAG, "audio visibility change", JSON.stringify(state));
|
|
314
|
+
if (state.status == "show") {
|
|
315
|
+
if (typeof this._propCache["customerPause"] != "undefined") {
|
|
316
|
+
const customerPause = this._propCache["customerPause"];
|
|
317
|
+
delete this._propCache["customerPause"];
|
|
318
|
+
if (!customerPause) {
|
|
319
|
+
this.play();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
// pause when invisible
|
|
324
|
+
this._propCache["customerPause"] = this._propCache["paused"];
|
|
325
|
+
this.pause();
|
|
301
326
|
}
|
|
302
327
|
}
|
|
303
328
|
}
|
|
304
329
|
|
|
305
|
-
export { sAudioManager };
|
|
330
|
+
export { sAudioManager, getKeyToken };
|
|
@@ -1,151 +1,138 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { sAudioManager } from "./AudioProxy.js";
|
|
1
|
+
<script setup>
|
|
2
|
+
import { sAudioManager, getKeyToken } from "./AudioProxy.js";
|
|
3
|
+
import { onBeforeUnmount } from "vue";
|
|
3
4
|
|
|
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
|
-
return {};
|
|
38
|
-
},
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
/**
|
|
7
|
+
* 回调函数,播放器对象通知接口
|
|
8
|
+
* @param {Object} video对象,可以通过此video对象调用video相关属性和方法,具体属性和方法定义见JsvMedia.js文件里相关说明。
|
|
9
|
+
*/
|
|
10
|
+
onRef: { type: Function, default: () => {} },
|
|
11
|
+
/**
|
|
12
|
+
* 属性,Boolean类型,true表示自动播放,默认false。
|
|
13
|
+
*/
|
|
14
|
+
autoplay: { type: Boolean, default: false },
|
|
15
|
+
/**
|
|
16
|
+
* 属性,String类型,播放器实例索引,同样的key使用同一个播放器实例。
|
|
17
|
+
*/
|
|
18
|
+
playerKey: { type: String, default: null },
|
|
19
|
+
/**
|
|
20
|
+
* 属性,Boolean类型,true表示静音,默认false。
|
|
21
|
+
*/
|
|
22
|
+
muted: { type: Boolean, default: false },
|
|
23
|
+
/**
|
|
24
|
+
* 属性,Boolean类型,true表示循环播放,默认false。
|
|
25
|
+
*/
|
|
26
|
+
loop: { type: Boolean, default: false },
|
|
27
|
+
/**
|
|
28
|
+
* 属性,String类型,播放地址。
|
|
29
|
+
*/
|
|
30
|
+
src: { type: String, default: "" },
|
|
31
|
+
/**
|
|
32
|
+
* 回调函数,播放结束时通过此回调接口通知。
|
|
33
|
+
*/
|
|
34
|
+
onEnded: {
|
|
35
|
+
type: Function,
|
|
36
|
+
default: () => {
|
|
37
|
+
return {};
|
|
39
38
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* 回调函数,开始加载,设置完播放地址后,上报此事件。
|
|
52
|
-
*/
|
|
53
|
-
onLoadStart: {
|
|
54
|
-
type: Function,
|
|
55
|
-
default: () => {
|
|
56
|
-
return {};
|
|
57
|
-
},
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* 回调函数,播放错误时通过此接口通知。
|
|
42
|
+
* @param {int} 错误类型,当前定义了四种错误。1是异常中断;2是网络错误;3是解码错误;4是格式不支持。
|
|
43
|
+
*/
|
|
44
|
+
onError: {
|
|
45
|
+
type: Function,
|
|
46
|
+
default: () => {
|
|
47
|
+
return {};
|
|
58
48
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* 回调函数,开始加载,设置完播放地址后,上报此事件。
|
|
52
|
+
*/
|
|
53
|
+
onLoadStart: {
|
|
54
|
+
type: Function,
|
|
55
|
+
default: () => {
|
|
56
|
+
return {};
|
|
67
57
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* 回调函数,视频准备好后触发。
|
|
61
|
+
*/
|
|
62
|
+
onLoadedMetaData: {
|
|
63
|
+
type: Function,
|
|
64
|
+
default: () => {
|
|
65
|
+
return {};
|
|
76
66
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* 回调函数,视频准备好后触发,这个时候可以正常seek。
|
|
70
|
+
*/
|
|
71
|
+
onLoad: {
|
|
72
|
+
type: Function,
|
|
73
|
+
default: () => {
|
|
74
|
+
return {};
|
|
85
75
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* 回调函数,音频失去焦点后触发此事件,可能会导致pause(点播)或者离开频道(直播)。
|
|
79
|
+
*/
|
|
80
|
+
onAudioFocusLoss: {
|
|
81
|
+
type: Function,
|
|
82
|
+
default: () => {
|
|
83
|
+
return {};
|
|
94
84
|
},
|
|
95
85
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
/**
|
|
87
|
+
* 回调函数,音频获取焦点后触发此事件,可能会触发resume(点播)或者加入频道(直播)。
|
|
88
|
+
*/
|
|
89
|
+
onAudioFocusGain: {
|
|
90
|
+
type: Function,
|
|
91
|
+
default: () => {
|
|
92
|
+
return {};
|
|
93
|
+
},
|
|
100
94
|
},
|
|
101
|
-
|
|
102
|
-
let key = "JsvAudio_" + Math.floor(Math.random() * 10000);
|
|
103
|
-
if (this.playerKey) {
|
|
104
|
-
key = this.playerKey;
|
|
105
|
-
}
|
|
106
|
-
console.log("player key:" + key);
|
|
95
|
+
});
|
|
107
96
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
let key = "JsvAudio_" + getKeyToken();
|
|
98
|
+
if (props.playerKey) {
|
|
99
|
+
key = props.playerKey;
|
|
100
|
+
}
|
|
101
|
+
console.log("player key:" + key);
|
|
102
|
+
const audio = sAudioManager.createAudio(key);
|
|
103
|
+
//register listener
|
|
104
|
+
audio.addEventListener("ended", props.onEnded);
|
|
105
|
+
audio.addEventListener("error", props.onError);
|
|
106
|
+
audio.addEventListener("loadstart", props.onLoadStart);
|
|
107
|
+
audio.addEventListener("loadedmetadata", props.onLoadedMetaData);
|
|
108
|
+
audio.addEventListener("load", props.onLoad);
|
|
109
|
+
audio.addEventListener("audiofocusloss", props.onAudioFocusLoss);
|
|
110
|
+
audio.addEventListener("audiofocusgain", props.onAudioFocusGain);
|
|
111
|
+
// ste props
|
|
112
|
+
if (props.src && props.src !== "") {
|
|
113
|
+
audio.src = props.src;
|
|
114
|
+
}
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
if (props.autoplay) {
|
|
117
|
+
audio.autoplay = props.autoplay;
|
|
118
|
+
}
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
if (props.muted) {
|
|
121
|
+
audio.muted = props.muted;
|
|
122
|
+
}
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.onRef?.(this.audio);
|
|
126
|
-
},
|
|
124
|
+
if (props.loop) {
|
|
125
|
+
audio.loop = props.loop;
|
|
126
|
+
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
if (this.audio != null) {
|
|
130
|
-
this.audio.release();
|
|
131
|
-
this.onRef?.(null);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
128
|
+
props.onRef?.(audio);
|
|
134
129
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.audio.addEventListener("loadedmetadata", this.onLoadedMetaData);
|
|
142
|
-
this.audio.addEventListener("load", this.onLoad);
|
|
143
|
-
this.audio.addEventListener("audiofocusloss", this.onAudioFocusLoss);
|
|
144
|
-
this.audio.addEventListener("audiofocusgain", this.onAudioFocusGain);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
};
|
|
130
|
+
onBeforeUnmount(() => {
|
|
131
|
+
if (audio != null) {
|
|
132
|
+
audio.release();
|
|
133
|
+
props.onRef?.(null);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
149
136
|
</script>
|
|
150
137
|
|
|
151
138
|
<template>
|
|
@@ -1,53 +1,382 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
2
|
+
import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
|
|
3
|
+
import { shallowRef } from "vue"
|
|
4
|
+
|
|
5
|
+
let logDebug = console.log;
|
|
3
6
|
|
|
4
7
|
export default {
|
|
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
|
-
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* 回调函数,播放器对象通知接口
|
|
11
|
+
* @param {Object} video对象,可以通过此video对象调用video相关属性和方法,具体属性和方法定义见JsvMedia.js文件里相关说明。
|
|
12
|
+
*/
|
|
13
|
+
onRef: { type: Function, default: () => {} },
|
|
14
|
+
/**
|
|
15
|
+
* 属性,Boolean类型,true表示自动播放,默认false。
|
|
16
|
+
*/
|
|
17
|
+
autoplay: { type: Boolean, default: false },
|
|
18
|
+
/**
|
|
19
|
+
* 属性,String类型,播放器实例索引,同样的key使用同一个播放器实例。
|
|
20
|
+
*/
|
|
21
|
+
playerKey: { type: String, default: null},
|
|
22
|
+
/**
|
|
23
|
+
* 属性,String类型,播放器窗口模式,默认resizable模式。
|
|
24
|
+
* full:观影模式,全屏方式,不建议修改w/h/l/t,视频清晰度/流畅度最佳;
|
|
25
|
+
* resizable:可变窗口模式,可以随意修改w/h/l/t,支持动画效果,视频清晰度/流畅度表现可能不如full模式;
|
|
26
|
+
* pip:画中画模式,只在支持多路硬解的情况下使用,用户画中画的小窗播放,对清晰度/流畅度要求较差,可能会有反交错问题。
|
|
27
|
+
*/
|
|
28
|
+
windowMode: {type: String, default: "resizable"},
|
|
29
|
+
/**
|
|
30
|
+
* 属性,int类型,底层使用的播放器类型。1:系统播放器;2:jsv播放器。默认2。
|
|
31
|
+
*/
|
|
32
|
+
playerType: {type: Number, default: 2},
|
|
33
|
+
/**
|
|
34
|
+
* 属性,int类型,播放器解码方式。0:根据硬件能力自动匹配;1:硬解码;2:软解码。默认0(根据芯片能力自动匹配)。
|
|
35
|
+
*/
|
|
36
|
+
decodeType: {type: Number, default: 0},
|
|
37
|
+
/**
|
|
38
|
+
* 属性,Boolean类型,层级关系,true表示在界面的下面,false表示在界面上面,默认true。
|
|
39
|
+
*/
|
|
40
|
+
background: {type: Boolean, default: true},
|
|
41
|
+
/**
|
|
42
|
+
* 属性,Boolean类型,true表示静音,默认false。
|
|
43
|
+
*/
|
|
44
|
+
muted: {type: Boolean, default: false},
|
|
45
|
+
/**
|
|
46
|
+
* 属性,Boolean类型,true表示循环播放,默认false。
|
|
47
|
+
*/
|
|
48
|
+
loop:{type: Boolean, default: false},
|
|
49
|
+
/**
|
|
50
|
+
* 属性,String类型,播放地址。
|
|
51
|
+
*/
|
|
52
|
+
src: {type: String, default: ""},
|
|
53
|
+
/**
|
|
54
|
+
* 属性,Double类型,起播时间,0-duration。
|
|
55
|
+
*/
|
|
56
|
+
currentTime: { type: Number, default: 0},
|
|
57
|
+
/**
|
|
58
|
+
* 属性,Boolean类型,是否保留最后一帧,true保留,false不保留。
|
|
59
|
+
*/
|
|
60
|
+
keepLastFrame: {type: Boolean, default: true},
|
|
61
|
+
/**
|
|
62
|
+
* 属性,String类型,视频显示比例,origin原始比例显示,full全屏显示,x:y按照指定比例显示。
|
|
63
|
+
*/
|
|
64
|
+
videoAspectRatio: {type: String, default: "origin"},
|
|
65
|
+
/**
|
|
66
|
+
* 属性,JSON Object类型,色度抠像参数,包含color,colorDistance,edgeDistance,greenOffset四个参数,
|
|
67
|
+
* 参考格式:{color: 0x30FF30, colorDistance: 0.15, edgeDistance: 0.4, greenOffset: 0.05}
|
|
68
|
+
* color,色值,int类型,为抠图色值范围的中心点,格式为0xRRGGBB。
|
|
69
|
+
* colorDistance,float类型,色域范围,范围0-1.0。
|
|
70
|
+
* edgeDistance,float类型,alpha透明度距离,范围colorDistance-1.0,从colorDistance到edgeDistance的alpha值从1.0-0线性递减。
|
|
71
|
+
* greenOffset,float类型,红蓝差值,范围0-1.0。
|
|
72
|
+
* 目前只支持扣绿。
|
|
73
|
+
*/
|
|
74
|
+
chromaKey: {type: Object, default: null},
|
|
75
|
+
/**
|
|
76
|
+
* 回调函数,播放结束时通过此回调接口通知。
|
|
77
|
+
*/
|
|
78
|
+
onEnded: {type: Function, default: ()=>{return{}}},
|
|
79
|
+
/**
|
|
80
|
+
* 回调函数,播放错误时通过此接口通知。
|
|
81
|
+
* @param {int} 错误类型,当前定义了四种错误。1是异常中断;2是网络错误;3是解码错误;4是格式不支持。
|
|
82
|
+
*/
|
|
83
|
+
onError: {type: Function, default: ()=>{return{}}},
|
|
84
|
+
// onAbort: {type: Function, default: ()=>{return{}}},
|
|
85
|
+
/**
|
|
86
|
+
* 回调函数,当正常播放时,每0.5秒上报一次,回调接口里会带上当前时间,也可以使用video对象的currentTime属性去获取当前时间。
|
|
87
|
+
* @param {Long} 当前播放时间,单位秒。
|
|
88
|
+
*/
|
|
89
|
+
onTimeUpdate: {type: Function, default: ()=>{return{}}},
|
|
90
|
+
/**
|
|
91
|
+
* 回调函数,开始加载,设置完播放地址后,上报此事件。
|
|
92
|
+
*/
|
|
93
|
+
onLoadStart: {type: Function, default: ()=>{return{}}},
|
|
94
|
+
/**
|
|
95
|
+
* 回调函数,开始正常播放,同一个播放地址仅触发一次。
|
|
96
|
+
*/
|
|
97
|
+
onCanPlayThrough: {type: Function, default: ()=>{return{}}},
|
|
98
|
+
/**
|
|
99
|
+
* 回调函数,正常下载,duration不变的情况下只触发一次。
|
|
100
|
+
*/
|
|
101
|
+
onProgress: {type: Function, default: ()=>{return{}}},
|
|
102
|
+
/**
|
|
103
|
+
* 回调函数,视频准备好后触发。
|
|
104
|
+
*/
|
|
105
|
+
onLoadedMetaData: {type: Function, default: ()=>{return{}}},
|
|
106
|
+
/**
|
|
107
|
+
* 回调函数,视频准备好后触发,这个时候可以正常seek。
|
|
108
|
+
*/
|
|
109
|
+
onLoad: {type: Function, default: ()=>{return{}}},
|
|
110
|
+
/**
|
|
111
|
+
* 回调函数,视频准备好后触发,这个时候可以获取duration。
|
|
112
|
+
*/
|
|
113
|
+
onDurationChange: {type: Function, default: ()=>{return{}}},
|
|
114
|
+
/**
|
|
115
|
+
* 回调函数,视频准备好后,seek(修改currentTime)会出发此事件。
|
|
116
|
+
*/
|
|
117
|
+
onSeeking: {type: Function, default: ()=>{return{}}},
|
|
118
|
+
/**
|
|
119
|
+
* 回调函数,seek完成后触发此事件。
|
|
120
|
+
*/
|
|
121
|
+
onSeeked: {type: Function, default: ()=>{return{}}},
|
|
122
|
+
/**
|
|
123
|
+
* 回调函数,缓冲时触发。
|
|
124
|
+
*/
|
|
125
|
+
onStalled: {type: Function, default: ()=>{return{}}},
|
|
126
|
+
/**
|
|
127
|
+
* 回调函数,正常播放后触发。
|
|
128
|
+
*/
|
|
129
|
+
onPlaying: {type: Function, default: ()=>{return{}}},
|
|
130
|
+
/**
|
|
131
|
+
* 回调函数,正常显示后触发此事件。
|
|
132
|
+
*/
|
|
133
|
+
onCanPlay: {type: Function, default: ()=>{return{}}},
|
|
134
|
+
/**
|
|
135
|
+
* 回调函数,音频失去焦点后触发此事件,可能会导致pause(点播)或者离开频道(直播)。
|
|
136
|
+
*/
|
|
137
|
+
onAudioFocusLoss: {type: Function, default: ()=>{return{}}},
|
|
138
|
+
/**
|
|
139
|
+
* 回调函数,音频获取焦点后触发此事件,可能会触发resume(点播)或者加入频道(直播)。
|
|
140
|
+
*/
|
|
141
|
+
onAudioFocusGain: {type: Function, default: ()=>{return{}}},
|
|
142
|
+
/**
|
|
143
|
+
* 回调函数,直播进入时移状态时,触发此事件。
|
|
144
|
+
*/
|
|
145
|
+
onTimeShift: {type: Function, default: ()=>{return{}}},
|
|
146
|
+
/**
|
|
147
|
+
* 回调函数,直播进入时移状态时,成功播放触发此事件。
|
|
148
|
+
*/
|
|
149
|
+
onTimeShifted: {type: Function, default: ()=>{return{}}},
|
|
150
|
+
/**
|
|
151
|
+
* 回调函数,时移回到直播状态,触发此事件。
|
|
152
|
+
*/
|
|
153
|
+
onBackLive: {type: Function, default: ()=>{return{}}},
|
|
154
|
+
/**
|
|
155
|
+
* 回调函数,时移回到直播状态时,成功播放触发此事件。
|
|
156
|
+
*/
|
|
157
|
+
onBackLived: {type: Function, default: ()=>{return{}}},
|
|
158
|
+
/**
|
|
159
|
+
* 属性,Object类型,设置窗口属性,同其他组件的style设置。
|
|
160
|
+
*/
|
|
161
|
+
style: {type: Object, default: ()=>{return{}}},
|
|
162
|
+
/**
|
|
163
|
+
* 属性,Boolean类型,活跃状态,当多个JsvPlayer组件指向一个video对象时,只能有一个处于活跃状态。
|
|
164
|
+
* 视频显示在活跃JsvPlayer设置的显示区域内,事件通知也只会送给活跃的JsvPlayer组件注册的回调函数。
|
|
165
|
+
*/
|
|
166
|
+
active:{type: Boolean, default: true},
|
|
167
|
+
},
|
|
168
|
+
components: {
|
|
169
|
+
|
|
170
|
+
},
|
|
171
|
+
watch: {
|
|
172
|
+
active(newValue) {
|
|
173
|
+
console.log("LudlDebug active newValue: "+newValue);
|
|
174
|
+
if(this.video){
|
|
175
|
+
if(newValue){
|
|
176
|
+
this.registerEvent();
|
|
177
|
+
this.video.setHoleID(this.holeId);
|
|
178
|
+
this.holeStyle = {
|
|
179
|
+
left: 0, top: 0,
|
|
180
|
+
width: this.style.width, height: this.style.height
|
|
181
|
+
};
|
|
182
|
+
}else{
|
|
183
|
+
this.holeStyle = {
|
|
184
|
+
left: 0, top: 0,
|
|
185
|
+
width: 0, height: 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
style(newValue){
|
|
191
|
+
logDebug("holeStyle newValue: left="+newValue.left+", top="+newValue.top+", width="+newValue.width+", height="+newValue.height);
|
|
192
|
+
if(this.active){
|
|
193
|
+
this.holeStyle = {
|
|
194
|
+
left: 0, top: 0,
|
|
195
|
+
width:newValue.width, height:newValue.height
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
keepLastFrame(newValue){
|
|
200
|
+
logDebug("keepLastFrame newValue: "+newValue);
|
|
201
|
+
if(this.video && this.active){
|
|
202
|
+
this.video.keepLastFrame = this.keepLastFrame;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
setup(){
|
|
208
|
+
return {
|
|
209
|
+
video: null,
|
|
210
|
+
holeId: "",
|
|
211
|
+
jsvMainView: shallowRef(null),
|
|
212
|
+
innerViewId: shallowRef(-1),
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
data() {
|
|
217
|
+
return {
|
|
218
|
+
holeStyle: {},
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
created() {
|
|
222
|
+
},
|
|
223
|
+
mounted() {
|
|
224
|
+
logDebug("JsvPlayer:",this.style)
|
|
225
|
+
|
|
226
|
+
let key = "Jsv_" + Math.floor(Math.random() * 10000);
|
|
227
|
+
if(this.playerKey){
|
|
228
|
+
key = this.playerKey;
|
|
229
|
+
}
|
|
230
|
+
logDebug("player key:"+key)
|
|
231
|
+
|
|
232
|
+
let player_type = 1;
|
|
233
|
+
if(this.playerType)
|
|
234
|
+
player_type = this.playerType;
|
|
235
|
+
|
|
236
|
+
let background = true;
|
|
237
|
+
if(!this.background)
|
|
238
|
+
background = this.background;
|
|
239
|
+
|
|
240
|
+
logDebug("JsvPlayer background:"+background)
|
|
241
|
+
|
|
242
|
+
const designMap = window.Forge.DesignMap();
|
|
243
|
+
logDebug("JsvPlayer:", this.holeId)
|
|
244
|
+
|
|
245
|
+
// this.video = findMediaObjectByKey(key);
|
|
246
|
+
// TODO: 后续支持共享MediaId ?
|
|
247
|
+
let first_create = true;
|
|
248
|
+
|
|
249
|
+
if(!this.video){
|
|
250
|
+
// 创建PC版本的video标签
|
|
251
|
+
this.video = window.originDocument.createElement("video");
|
|
252
|
+
}else{
|
|
253
|
+
this.video.setRef();
|
|
254
|
+
first_create = false;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if(this.video != null){
|
|
258
|
+
if(this.active){
|
|
259
|
+
this.registerEvent();
|
|
260
|
+
|
|
261
|
+
//if(first_create){
|
|
262
|
+
if(this.src && this.src !== "")
|
|
263
|
+
this.video.src = this.src;
|
|
264
|
+
|
|
265
|
+
if(this.currentTime !== 0)
|
|
266
|
+
this.video.currentTime = this.currentTime;
|
|
267
|
+
|
|
268
|
+
if(this.autoplay){
|
|
269
|
+
this.video.autoplay = this.autoplay;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if(this.muted){
|
|
273
|
+
this.video.muted = this.muted;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if(this.loop){
|
|
277
|
+
this.video.loop = this.loop;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if(!this.keepLastFrame){
|
|
281
|
+
this.video.keepLastFrame = this.keepLastFrame;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if(this.videoAspectRatio !== "origin"){
|
|
285
|
+
this.video.videoAspectRatio = this.videoAspectRatio;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if(this.chromaKey && this.chromaKey !== ""){
|
|
289
|
+
this.video.setChromaKey(this.chromaKey)
|
|
290
|
+
}
|
|
291
|
+
//}else{
|
|
292
|
+
if(!first_create){
|
|
293
|
+
this.video.setHoleID(this.holeId);
|
|
294
|
+
this.holeStyle = {
|
|
295
|
+
left: 0, top: 0,
|
|
296
|
+
width: this.style.width, height: this.style.height
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// 创建挂载的VideoView
|
|
302
|
+
this.jsvMainView = new Forge.VideoView(this.video, null);
|
|
303
|
+
this.innerViewId = Forge.sViewStore.add(
|
|
304
|
+
new Forge.ViewInfo(this.jsvMainView)
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
this.onRef?.(this.video)
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
unmounted(){
|
|
312
|
+
if(this.video != null) {
|
|
313
|
+
// 清理View管理缓存
|
|
314
|
+
if (this.innerViewId !== -1) {
|
|
315
|
+
Forge.sViewStore.remove(this.innerViewId);
|
|
316
|
+
this.innerViewId = -1;
|
|
317
|
+
this.jsvMainView = null;
|
|
32
318
|
}
|
|
319
|
+
this.onRef?.(null)
|
|
320
|
+
}
|
|
321
|
+
},
|
|
33
322
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
323
|
+
methods: {
|
|
324
|
+
getHoleId(id){
|
|
325
|
+
logDebug("getHoleId:", id)
|
|
326
|
+
this.holeId = id;
|
|
327
|
+
},
|
|
328
|
+
registerEvent(){
|
|
329
|
+
if(this.video && this.active){
|
|
330
|
+
this.video.addEventListener("end", this.onEnded);
|
|
331
|
+
this.video.addEventListener("error", this.onError);
|
|
332
|
+
//this.video.addEventListener("abort", this.onAbort);
|
|
333
|
+
this.video.addEventListener("timeupdate", this.onTimeUpdate);
|
|
334
|
+
this.video.addEventListener("loadstart", () => {
|
|
335
|
+
logDebug("JsvPlayer received loadstart event.");
|
|
336
|
+
this.holeStyle = {
|
|
337
|
+
left: 0, top: 0,
|
|
338
|
+
width:this.style.width, height:this.style.height
|
|
339
|
+
};
|
|
340
|
+
this.onLoadStart();
|
|
341
|
+
});
|
|
342
|
+
this.video.addEventListener("canplaythrough", this.onCanPlayThrough);
|
|
343
|
+
this.video.addEventListener("progress", this.onProgress);
|
|
344
|
+
this.video.addEventListener("loadedmetadata", this.onLoadedMetaData);
|
|
345
|
+
this.video.addEventListener("load", this.onLoad);
|
|
346
|
+
this.video.addEventListener("durationchange", this.onDurationChange);
|
|
347
|
+
this.video.addEventListener("seeking", this.onSeeking);
|
|
348
|
+
this.video.addEventListener("seeked", this.onSeeked);
|
|
349
|
+
this.video.addEventListener("stalled", this.onStalled);
|
|
350
|
+
this.video.addEventListener("playing", this.onPlaying);
|
|
351
|
+
this.video.addEventListener("canplay", this.onCanPlay);
|
|
352
|
+
this.video.addEventListener("audiofocusloss", this.onAudioFocusLoss);
|
|
353
|
+
this.video.addEventListener("audiofocusgain", this.onAudioFocusGain);
|
|
354
|
+
this.video.addEventListener("timeshift", this.onTimeShift);
|
|
355
|
+
this.video.addEventListener("timeshifted", this.onTimeShifted);
|
|
356
|
+
this.video.addEventListener("backlive", this.onBackLive);
|
|
357
|
+
this.video.addEventListener("backlived", this.onBackLived);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
}
|
|
45
362
|
|
|
363
|
+
//export default JsvPlayer;
|
|
46
364
|
</script>
|
|
47
365
|
|
|
48
366
|
<template>
|
|
49
|
-
<
|
|
367
|
+
<div :style="holeStyle" backgroundColor="rgba(0,0,0,1)">
|
|
368
|
+
<div
|
|
369
|
+
:style="{
|
|
370
|
+
left: holeStyle.left,
|
|
371
|
+
top: holeStyle.top,
|
|
372
|
+
width: holeStyle.width,
|
|
373
|
+
height: holeStyle.height,
|
|
374
|
+
}"
|
|
375
|
+
:data-jsv-vw-innerview="innerViewId"
|
|
376
|
+
/>
|
|
377
|
+
</div>
|
|
50
378
|
</template>
|
|
51
379
|
|
|
52
380
|
<style scoped>
|
|
53
|
-
|
|
381
|
+
|
|
382
|
+
</style>
|
|
@@ -50,7 +50,8 @@ class JsvHashHistory {
|
|
|
50
50
|
|
|
51
51
|
#createMockHashHistory(base) {
|
|
52
52
|
// 抄 createWebHashHistory 作业
|
|
53
|
-
base = location.host ? base || location.pathname + location.search : '';
|
|
53
|
+
// base = location.host ? base || location.pathname + location.search : '';
|
|
54
|
+
base = (location.host || location.protocol === 'file:') ? base || location.pathname + location.search : '';
|
|
54
55
|
if (!base.includes('#'))
|
|
55
56
|
base += '#';
|
|
56
57
|
if (!base.endsWith('#/') && !base.endsWith('#')) {
|
|
@@ -107,46 +107,7 @@ export default {
|
|
|
107
107
|
};
|
|
108
108
|
},
|
|
109
109
|
mounted() {
|
|
110
|
-
|
|
111
|
-
if (this.playerKey) {
|
|
112
|
-
key = this.playerKey;
|
|
113
|
-
}
|
|
114
|
-
console.log("player key:" + key);
|
|
115
|
-
|
|
116
|
-
this.audio = new Audio();
|
|
117
|
-
this.registerEvent();
|
|
118
|
-
if (this.src && this.src !== "") {
|
|
119
|
-
let realUrl
|
|
120
|
-
if (window.JsView) {
|
|
121
|
-
// jsview上
|
|
122
|
-
realUrl = new window.JsView.Dom.UrlRef(this.src).href;
|
|
123
|
-
} else {
|
|
124
|
-
realUrl = this.src;
|
|
125
|
-
}
|
|
126
|
-
this.audio.src = realUrl;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (this.autoplay) {
|
|
130
|
-
this.audio.autoplay = this.autoplay;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (this.muted) {
|
|
134
|
-
this.audio.muted = this.muted;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (this.loop) {
|
|
138
|
-
this.audio.loop = this.loop;
|
|
139
|
-
}
|
|
140
|
-
if (this.preDownload) {
|
|
141
|
-
this.audio.predownload = this.preDownload;
|
|
142
|
-
}
|
|
143
|
-
this.onRef?.(this.audio);
|
|
144
|
-
//初始化
|
|
145
|
-
Promise.resolve().then(() => {
|
|
146
|
-
if (this.audio) {
|
|
147
|
-
this.audio.confirmInitSetup?.();
|
|
148
|
-
}
|
|
149
|
-
});
|
|
110
|
+
this.Jsvinit()
|
|
150
111
|
},
|
|
151
112
|
|
|
152
113
|
beforeUnmount() {
|
|
@@ -155,6 +116,7 @@ export default {
|
|
|
155
116
|
this.audio.releaseResource?.();
|
|
156
117
|
this.audio.onPlatformDestroy?.();
|
|
157
118
|
this.onRef?.(null);
|
|
119
|
+
this.unregisterOnVisibilityChange()
|
|
158
120
|
}
|
|
159
121
|
},
|
|
160
122
|
|
|
@@ -170,6 +132,86 @@ export default {
|
|
|
170
132
|
this.audio.addEventListener("audiofocusgain", this.onAudioFocusGain);
|
|
171
133
|
}
|
|
172
134
|
},
|
|
135
|
+
onVisibilityChange(status) {
|
|
136
|
+
if (status.status === "show") {
|
|
137
|
+
this.onJsViewShow();
|
|
138
|
+
} else if (status.status === "hide") {
|
|
139
|
+
this.onJsViewHide();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
registerOnVisibilityChange() {
|
|
143
|
+
if (window.JsView) {
|
|
144
|
+
window.JsView.onVisibilityChange(this.onVisibilityChange);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
unregisterOnVisibilityChange() {
|
|
148
|
+
if (window.JsView) {
|
|
149
|
+
window.JsView.removeEventCallback(this.onVisibilityChange);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
onJsViewHide() {
|
|
153
|
+
if (this.audio) {
|
|
154
|
+
//释放
|
|
155
|
+
if (!this.audio.paused) {
|
|
156
|
+
this.stopByOnHide = true;
|
|
157
|
+
}
|
|
158
|
+
this.audio.unload();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
onJsViewShow() {
|
|
162
|
+
//重新加载
|
|
163
|
+
if (!this.audio) {
|
|
164
|
+
this.Jsvinit()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (this.stopByOnHide) {
|
|
168
|
+
this.stopByOnHide = false;
|
|
169
|
+
this.Jsvinit()
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
Jsvinit() {
|
|
173
|
+
let key = "JsvAudio_" + Math.floor(Math.random() * 10000);
|
|
174
|
+
if (this.playerKey) {
|
|
175
|
+
key = this.playerKey;
|
|
176
|
+
}
|
|
177
|
+
console.log("player key:" + key);
|
|
178
|
+
|
|
179
|
+
this.audio = new Audio();
|
|
180
|
+
this.registerEvent();
|
|
181
|
+
if (this.src && this.src !== "") {
|
|
182
|
+
let realUrl
|
|
183
|
+
if (window.JsView) {
|
|
184
|
+
// jsview上
|
|
185
|
+
realUrl = new window.JsView.Dom.UrlRef(this.src).href;
|
|
186
|
+
} else {
|
|
187
|
+
realUrl = this.src;
|
|
188
|
+
}
|
|
189
|
+
this.audio.src = realUrl;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.autoplay) {
|
|
193
|
+
this.audio.autoplay = this.autoplay;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (this.muted) {
|
|
197
|
+
this.audio.muted = this.muted;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (this.loop) {
|
|
201
|
+
this.audio.loop = this.loop;
|
|
202
|
+
}
|
|
203
|
+
if (this.preDownload) {
|
|
204
|
+
this.audio.predownload = this.preDownload;
|
|
205
|
+
}
|
|
206
|
+
this.onRef?.(this.audio);
|
|
207
|
+
//初始化
|
|
208
|
+
Promise.resolve().then(() => {
|
|
209
|
+
if (this.audio) {
|
|
210
|
+
this.audio.confirmInitSetup?.();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
this.registerOnVisibilityChange()
|
|
214
|
+
}
|
|
173
215
|
},
|
|
174
216
|
};
|
|
175
217
|
</script>
|