@shijiu/jsview-vue 0.9.684 → 0.9.783

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.
Files changed (154) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -1
  4. package/dom/bin/jsview-forge-define.min.js +1 -1
  5. package/dom/jsv-engine-js-browser.js +6 -0
  6. package/dom/target_core_revision.js +4 -4
  7. package/loader/loader.js +4 -0
  8. package/package.json +1 -1
  9. package/patches/node_modules/@vue/cli-service/lib/config/base.js +1 -1
  10. package/samples/AnimPicture/App.vue +5 -5
  11. package/samples/Basic/components/div/DivLayout.vue +1 -1
  12. package/samples/Basic/components/img/ImageGroup.vue +2 -2
  13. package/samples/Basic/components/img/ImgLayout.vue +79 -15
  14. package/samples/Basic/components/text/TextDirection.vue +104 -0
  15. package/samples/Basic/components/text/TextEmoji.vue +1 -1
  16. package/samples/Basic/components/text/TextGroup1.vue +1 -1
  17. package/samples/Basic/components/text/TextGroup2.vue +11 -1
  18. package/samples/BasicFocusControl/components/BaseBlock.vue +2 -2
  19. package/samples/Collision/App.vue +11 -11
  20. package/samples/DemoHomepage/App.vue +67 -8
  21. package/samples/DemoHomepage/components/TabFrame.vue +7 -0
  22. package/samples/DemoHomepage/router.js +27 -26
  23. package/samples/DemoHomepage/views/Homepage.vue +89 -98
  24. package/samples/FilterDemo/App.vue +1 -1
  25. package/samples/FlipCard/App.vue +2 -2
  26. package/samples/FlipCard/FlipCard.vue +3 -3
  27. package/samples/FocusBlockDemos/AutoFocus/App.vue +51 -0
  28. package/samples/FocusBlockDemos/AutoFocus/BaseBlock.vue +82 -0
  29. package/samples/FocusBlockDemos/AutoFocus/DialogBlock.vue +89 -0
  30. package/samples/FocusBlockDemos/AutoFocus/DialogContorls.js +42 -0
  31. package/samples/FocusBlockDemos/AutoFocus/FocusNamesDefine.js +9 -0
  32. package/samples/FocusBlockDemos/AutoFocus/PlaneBlock.vue +71 -0
  33. package/samples/FocusBlockDemos/ProgressiveFocusControl/App.vue +78 -0
  34. package/samples/FocusBlockDemos/ProgressiveFocusControl/BaseBlock.vue +77 -0
  35. package/samples/FocusBlockDemos/ProgressiveFocusControl/DownPlaneBlock.vue +83 -0
  36. package/samples/FocusBlockDemos/ProgressiveFocusControl/FocusNamesDefine.js +12 -0
  37. package/samples/FocusBlockDemos/ProgressiveFocusControl/UpPlaneBlock.vue +83 -0
  38. package/samples/GridDemo/App.vue +3 -3
  39. package/samples/GridDemo/ButtonBlock.vue +2 -2
  40. package/samples/GridDemo/FocusItem.vue +2 -2
  41. package/samples/GridDemo/Item.vue +1 -1
  42. package/samples/HashHistory/App.vue +10 -3
  43. package/samples/HashHistory/components/Item.vue +1 -1
  44. package/samples/ImpactStop/App.vue +15 -11
  45. package/samples/Input/InputPanel.vue +1 -1
  46. package/samples/LongImage/Button.vue +1 -1
  47. package/samples/LongImage/ButtonItem.vue +1 -1
  48. package/samples/LongImage/LongImageScroll.vue +2 -2
  49. package/samples/LongText/App.vue +1 -1
  50. package/samples/LongText/Button.vue +1 -1
  51. package/samples/LongText/ButtonItem.vue +1 -1
  52. package/samples/LongText/LongTextScroll.vue +3 -3
  53. package/samples/Marquee/App.vue +34 -3
  54. package/samples/Marquee/longText.js +2 -2
  55. package/samples/MetroWidgetDemos/PerformanceTest/App.vue +4 -4
  56. package/samples/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +1 -1
  57. package/samples/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +3 -3
  58. package/samples/MetroWidgetDemos/PingPong/App.vue +22 -11
  59. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +5 -5
  60. package/samples/MetroWidgetDemos/{Item.vue → PingPong/Item.vue} +3 -21
  61. package/samples/MetroWidgetDemos/PingPong/TabItem.vue +1 -1
  62. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +5 -5
  63. package/samples/MetroWidgetDemos/{WidgetItem.vue → PingPong/WidgetItem.vue} +8 -4
  64. package/samples/MetroWidgetDemos/basic/App.vue +162 -0
  65. package/samples/MetroWidgetDemos/basic/Item.vue +43 -0
  66. package/samples/MetroWidgetDemos/direction/App.vue +158 -0
  67. package/samples/MetroWidgetDemos/direction/Item.vue +45 -0
  68. package/samples/MetroWidgetDemos/focusableItemBasic/App.vue +67 -0
  69. package/samples/MetroWidgetDemos/{Advanced → focusableItemBasic}/ButtonItem.vue +17 -21
  70. package/samples/MetroWidgetDemos/focusableItemMetroWidget/App.vue +74 -0
  71. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/Item.vue +13 -32
  72. package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/WidgetItem.vue +12 -12
  73. package/samples/MetroWidgetDemos/focusableItemMix/App.vue +88 -0
  74. package/samples/MetroWidgetDemos/focusableItemMix/ButtonItem.vue +86 -0
  75. package/samples/MetroWidgetDemos/focusableItemMix/Item.vue +43 -0
  76. package/samples/MetroWidgetDemos/index.js +6 -0
  77. package/samples/MetroWidgetDemos/layoutType/App.vue +180 -0
  78. package/samples/MetroWidgetDemos/layoutType/Item.vue +45 -0
  79. package/samples/MetroWidgetDemos/padding/App.vue +222 -0
  80. package/samples/MetroWidgetDemos/padding/Item.vue +64 -0
  81. package/samples/MetroWidgetDemos/routeList.js +64 -0
  82. package/samples/MetroWidgetDemos/slideSetting/App.vue +225 -0
  83. package/samples/MetroWidgetDemos/slideSetting/Item.vue +45 -0
  84. package/samples/NinePatchDemo/App.vue +78 -122
  85. package/samples/NinePatchDemo/Item.vue +29 -27
  86. package/samples/Preload/App.vue +1 -1
  87. package/samples/Preload/Item.vue +1 -1
  88. package/samples/QrcodeDemo/App.vue +1 -1
  89. package/samples/SoundPool/App.vue +3 -3
  90. package/samples/SpriteImage/App.vue +5 -0
  91. package/samples/Swiper/App.vue +148 -0
  92. package/samples/TextBox/App.vue +2 -1
  93. package/samples/TextureAnimation/App2.vue +1 -1
  94. package/samples/ThrowMoveDemo/LRParabolicDemo.vue +33 -47
  95. package/samples/TouchSample/MetroWidgetHorizontal.vue +1 -1
  96. package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
  97. package/samples/TransitPage/App.vue +1 -1
  98. package/samples/VideoDemo/App.vue +8 -8
  99. package/samples/VideoDemo/components/Button.vue +1 -1
  100. package/samples/VideoDemo/components/Controllor.vue +1 -1
  101. package/samples/VisibleSensorDemo/App.vue +3 -3
  102. package/scripts/jsview-run-android.js +5 -4
  103. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +4 -4
  104. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +79 -50
  105. package/utils/JsViewEngineWidget/TemplateParser.js +144 -147
  106. package/utils/JsViewEngineWidget/WidgetCommon.js +12 -3
  107. package/utils/JsViewPlugin/BrowserPluginLoader.js +4 -2
  108. package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +302 -0
  109. package/utils/JsViewPlugin/JsvAudio/CheckType.js +68 -0
  110. package/utils/JsViewPlugin/JsvAudio/Events.js +17 -0
  111. package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +176 -0
  112. package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +40 -0
  113. package/utils/JsViewPlugin/JsvAudio/JsvAudioBrowser.vue +46 -0
  114. package/utils/JsViewPlugin/JsvAudio/PluginLoader.js +140 -0
  115. package/utils/JsViewPlugin/JsvAudio/index.js +26 -0
  116. package/utils/JsViewPlugin/JsvAudio/version.js +24 -0
  117. package/utils/JsViewPlugin/JsvPlayer/index.js +1 -1
  118. package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
  119. package/utils/JsViewVueTools/JsvHashHistory.js +34 -8
  120. package/utils/JsViewVueTools/JsvImpactTracer.js +2 -2
  121. package/utils/JsViewVueTools/JsvRuntimeBridge.js +46 -8
  122. package/utils/JsViewVueTools/JsvStyleClass.js +9 -0
  123. package/utils/{JsViewVueWidget/utils/text.js → JsViewVueTools/JsvTextTools.js} +24 -4
  124. package/utils/JsViewVueTools/TypeCheckAndSet.js +3 -3
  125. package/utils/JsViewVueTools/index.js +2 -1
  126. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +5 -7
  127. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +20 -22
  128. package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +4 -4
  129. package/utils/JsViewVueWidget/JsvGrid.vue +1 -9
  130. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +1 -1
  131. package/utils/JsViewVueWidget/JsvMarquee.vue +91 -20
  132. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +1 -1
  133. package/utils/JsViewVueWidget/JsvNinePatch.vue +63 -53
  134. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +10 -5
  135. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +2 -2
  136. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +116 -80
  137. package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -2
  138. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +1 -1
  139. package/utils/JsViewVueWidget/JsvTextBox.vue +11 -31
  140. package/utils/JsViewVueWidget/JsvTouchContainer.vue +2 -2
  141. package/utils/JsViewVueWidget/JsvTransparentDiv.vue +1 -1
  142. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +5 -5
  143. package/utils/JsViewVueWidget/index.js +8 -8
  144. package/samples/MetroWidgetDemos/Advanced/App.vue +0 -46
  145. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +0 -70
  146. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +0 -77
  147. package/samples/MetroWidgetDemos/Advanced/widgets/Widgets.vue +0 -116
  148. package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  149. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +0 -75
  150. package/samples/MetroWidgetDemos/Simple/App.vue +0 -45
  151. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +0 -111
  152. package/samples/MetroWidgetDemos/data.js +0 -205
  153. package/utils/JsViewVueWidget/JsvSwiper/Indicator.vue +0 -35
  154. package/utils/JsViewVueWidget/utils/index.js +0 -8
@@ -0,0 +1,302 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-02-22 15:43:56
4
+ * @Description: file content
5
+ */
6
+ import JsvAudioBridgeProxy from "./JsvAudioBridgeProxy";
7
+ import { checkType, toRawType } from "./CheckType";
8
+ import sPluginLoader from "./PluginLoader";
9
+ import Events from "./Events.js"
10
+
11
+ const TAG = "JsvAudio";
12
+
13
+ class AudioManager {
14
+ constructor() {
15
+ this.audioMap = {};
16
+ sPluginLoader.registerOnDoneListener(this.onPluginLoadDone.bind(this));
17
+ }
18
+
19
+ createAudio(id) {
20
+ if (!Object.hasOwn(this.audioMap, id)) {
21
+ this.audioMap[id] = new AudioProxy(id, this);
22
+ } else {
23
+ this.audioMap[id].ref()
24
+ }
25
+
26
+ if (!JsvAudioBridgeProxy.isReady()) {
27
+ sPluginLoader.loadPlugin();
28
+ } else {
29
+ this.audioMap[id].buildPlatformInstance();
30
+ }
31
+ return this.audioMap[id]
32
+ }
33
+
34
+ releaseAudio(id) {
35
+ delete this.audioMap[id];
36
+ }
37
+
38
+ onPluginLoadDone(status) {
39
+ for (let id in this.audioMap) {
40
+ this.audioMap[id].buildPlatformInstance();
41
+ }
42
+ }
43
+
44
+ onCreatePlayer(result) {
45
+ console.log("CreatePlayerResult: " + result);
46
+ let resultObj = JSON.parse(result);
47
+ if (resultObj.code == 0) {
48
+ this.audioMap[resultObj.key]?.initPlayer();
49
+ } else {
50
+ console.error("Create player failed, key=" + resultObj.key);
51
+ }
52
+ }
53
+ }
54
+ const sAudioManager = new AudioManager();
55
+
56
+ window.top.CreatePlayerResult = sAudioManager.onCreatePlayer.bind(sAudioManager);
57
+
58
+ const AUDIO_PROPS = {
59
+ "src": { type: Object },
60
+ "paused": { type: Boolean },
61
+ "autoplay": { type: Boolean },
62
+ "volume": { type: Number },
63
+ "muted": { type: Boolean },
64
+ "loop": { type: Boolean },
65
+ "enablePlayer": { type: Boolean },
66
+ }
67
+
68
+ class AudioProxy {
69
+ constructor(id, audioManager) {
70
+ this._onEvent = this.onEvent.bind(this);
71
+ this._playerId = id;
72
+ this._ref = 1;
73
+ this._audioManager = audioManager;
74
+ this._created = false;
75
+ this._eventListener = {};
76
+ this._propCache = {};
77
+ }
78
+
79
+ /** 初始化函数, 外部不应该调用 */
80
+ buildPlatformInstance() {
81
+ console.log("buildPlatformInstance, key=" + this._playerId);
82
+ if (!JsvAudioBridgeProxy.isReady()) {
83
+ console.error("no jsvAudioBridge");
84
+ return;
85
+ }
86
+ let result = JsvAudioBridgeProxy.CreateAudio(this._playerId, "top.CreatePlayerResult");
87
+ console.log("JsvAudio CreateAudio result ", result);
88
+ if (result > 0) {
89
+ this.initPlayer();
90
+ }
91
+ }
92
+
93
+ initPlayer() {
94
+ if (this._created) return;
95
+
96
+ console.log("InitPlayer:1, key=" + this._playerId);
97
+ this._created = true;
98
+
99
+ window.JMD.subscribe(this._playerId, this._onEvent);
100
+ this.initParams();
101
+ }
102
+
103
+ initParams() {
104
+ if (this._propCache["src"]) {
105
+ this.setProperty("src", this._propCache["src"]);
106
+ }
107
+
108
+ if (this._propCache["paused"] == false) {
109
+ this.setProperty("paused", this._propCache["paused"]);
110
+ }
111
+
112
+ if (this._propCache["autoplay"]) {
113
+ this.setProperty("autoplay", this._propCache["autoplay"]);
114
+ }
115
+
116
+ if (this._propCache["loop"]) {
117
+ this.setProperty("loop", this._propCache["loop"]);
118
+ }
119
+
120
+ if (this._propCache["muted"]) {
121
+ this.setProperty("muted", this._propCache["muted"]);
122
+ }
123
+ }
124
+ /*******/
125
+
126
+ /** events */
127
+ addEventListener(type, listener) {
128
+ if (listener) {
129
+ this._eventListener['on' + type] = listener;
130
+ }
131
+ }
132
+
133
+ callEventListener(name, ...params) {
134
+ this._eventListener[name]?.(...params);
135
+ }
136
+
137
+ onEvent(eventStr) {
138
+ console.log("player event: ", eventStr);
139
+ let obj = JSON.parse(eventStr);
140
+ let event_obj = JSON.parse(obj.param);
141
+ let event = event_obj.event;
142
+ let data = event_obj.data;
143
+ switch (event) {
144
+ case Events.EVENT_END:
145
+ this.setProperty("paused", true);
146
+ this.callEventListener("onend");
147
+ break;
148
+ case Events.EVENT_LOAD_START:
149
+ this.callEventListener("onloadstart");
150
+ break;
151
+ case Events.EVENT_LOAD:
152
+ this.callEventListener("onloadedmetadata");
153
+ this.callEventListener("onload");
154
+ this.callEventListener("ondurationchange");
155
+ break;
156
+ case Events.EVENT_ERROR:
157
+ const Error = {
158
+ MEDIA_ERR_ABORTED: 1,
159
+ MEDIA_ERR_NETWORK: 2,
160
+ MEDIA_ERR_DECODE: 3,
161
+ MEDIA_ERR_SRC_NOT_SUPPORTED: 4,
162
+ MEDIA_ERR_NO_DECODE_RESOURCE: 6,
163
+ };
164
+ const platform_error = data.error.what;
165
+ let e = Error.MEDIA_ERR_ABORTED;
166
+ switch (platform_error) {
167
+ case -1004: // MediaPlayer.MEDIA_ERROR_IO
168
+ e = Error.MEDIA_ERR_NETWORK;
169
+ break;
170
+ case -1007: // MediaPlayer.MEDIA_ERROR_MALFORMED
171
+ e = Error.MEDIA_ERR_DECODE;
172
+ break;
173
+ case -1010: // MediaPlayer.MEDIA_ERROR_UNSUPPORTED
174
+ e = Error.MEDIA_ERR_SRC_NOT_SUPPORTED;
175
+ break;
176
+ case -50002:
177
+ e = Error.MEDIA_ERR_NO_DECODE_RESOURCE;
178
+ break;
179
+ default:
180
+ break;
181
+ }
182
+ this.callEventListener("onerror", e);
183
+ break;
184
+ case Events.EVENT_EXT:
185
+ switch (data.eventExt) {
186
+ case "videoMetadataUpdate":
187
+ this.callEventListener("onloadedmetadata");
188
+ break;
189
+ default:
190
+ logWarning("unimplentation event ext type = " + data.eventExt);
191
+ break;
192
+ }
193
+ break;
194
+ default:
195
+ break;
196
+ }
197
+ }
198
+
199
+
200
+ /** control */
201
+ load() {
202
+ this.setProperty("enablePlayer", true);
203
+ }
204
+
205
+ play() {
206
+ this.setProperty("paused", false);
207
+ }
208
+
209
+ pause() {
210
+ this.setProperty("paused", true);
211
+ }
212
+
213
+ unload() {
214
+ this.pause();
215
+ this.setProperty("enablePlayer", false);
216
+ }
217
+
218
+ /** audio props */
219
+ /** src 不支持get */
220
+ set src(value) {
221
+ this.setSrc(value, null)
222
+ }
223
+
224
+ /** volume */
225
+ set volume(value) { this.setProperty("volume", value); }
226
+
227
+ get volume() { return this.getProperty("volume"); }
228
+
229
+ /** muted */
230
+ set muted(value) { this.setProperty("muted", value); }
231
+
232
+ get muted() { return this.getProperty("muted"); }
233
+
234
+ /** loop 不支持 get*/
235
+ set loop(value) { this.setProperty("loop", value); }
236
+
237
+ /** paused 不支持 set */
238
+ get paused() { return this.getProperty("paused"); }
239
+
240
+ /** autoplay 不支持 get */
241
+ set autoplay(value) { this.setProperty("autoplay", value); }
242
+
243
+ /** duration 不支持 set */
244
+ get duration() { return this.getProperty("duration"); }
245
+
246
+ /** current 目前不支持时移, 只能get */
247
+ get currentTime() { return this.getProperty("currentTime"); }
248
+
249
+ setSrc(url, head) {
250
+ const param = {
251
+ url: url,
252
+ head: JSON.stringify(head),
253
+ };
254
+ this.setProperty("src", param);
255
+ }
256
+
257
+ setProperty(key, value) {
258
+ if (AUDIO_PROPS.hasOwnProperty(key)) {
259
+ if (checkType(value, AUDIO_PROPS[key].type)) {
260
+ console.log(TAG, "setProperty", key, value)
261
+ this._propCache[key] = value;
262
+
263
+ if (this._created) {
264
+ const param = { [key]: value };
265
+ JsvAudioBridgeProxy.SetProperty(this._playerId, JSON.stringify(param));
266
+ }
267
+ } else {
268
+ console.error(TAG, `Invalid prop: type check failed for prop "${key}". Expected ${toRawType(AUDIO_PROPS[key].type)}, got ${toRawType(value)} with value ${value}.`);
269
+ }
270
+ } else {
271
+ console.error(TAG, `property ${key} not supported`);
272
+ }
273
+ }
274
+
275
+ getProperty(key) {
276
+ if (this._created) {
277
+ const jsonStr = JsvAudioBridgeProxy.GetProperty(this._playerId, key);
278
+ if (jsonStr) {
279
+ const obj = JSON.parse(jsonStr);
280
+ return obj[key];
281
+ }
282
+ }
283
+ return null;
284
+ }
285
+
286
+ ref() {
287
+ this._ref++;
288
+ console.log("JsvAudio ref up", this._ref);
289
+ }
290
+
291
+ release() {
292
+ this._ref--;
293
+ console.log("JsvAudio release", this._ref);
294
+ if (this._ref === 0) {
295
+ window.JMD.unsubscribe(this._playerId, this._onEvent);
296
+ JsvAudioBridgeProxy.ReleasePlayer(this._playerId);
297
+ this._audioManager.releaseAudio(this._playerId);
298
+ }
299
+ }
300
+ }
301
+
302
+ export { sAudioManager };
@@ -0,0 +1,68 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-02-23 10:40:16
4
+ * @Description: file content
5
+ */
6
+
7
+ const isArray = Array.isArray;
8
+ const isMap = (val) => Object.prototype.toString.call(val) === '[object Map]';
9
+ const isSet = (val) => Object.prototype.toString.call(val) === '[object Set]';
10
+ const isDate = (val) => Object.prototype.toString.call(val) === '[object Date]';
11
+ const isFunction = (val) => typeof val === 'function';
12
+ const isString = (val) => typeof val === 'string';
13
+ const isSymbol = (val) => typeof val === 'symbol';
14
+ const isObject = (val) => val !== null && typeof val === 'object';
15
+
16
+ function getType(ctor) {
17
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
18
+ return match ? match[1] : ctor === null ? 'null' : '';
19
+ }
20
+
21
+ const objectToString = Object.prototype.toString;
22
+
23
+ const toTypeString = (value) => objectToString.call(value);
24
+
25
+ const toRawType = (value) => {
26
+ // extract "RawType" from strings like "[object RawType]"
27
+ return toTypeString(value).slice(8, -1);
28
+ };
29
+
30
+ function makeMap(str, expectsLowerCase) {
31
+ const map = Object.create(null);
32
+ const list = str.split(',');
33
+ for (let i = 0; i < list.length; i++) {
34
+ map[list[i]] = true;
35
+ }
36
+ return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
37
+ }
38
+
39
+ const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
40
+
41
+ function checkType(value, type) {
42
+ if (typeof type === "undefined" || type === null) { return true;}
43
+ let valid;
44
+ const expectedType = getType(type);
45
+ if (isSimpleType(expectedType)) {
46
+ const t = typeof value;
47
+ valid = t === expectedType.toLowerCase();
48
+ // for primitive wrapper objects
49
+ if (!valid && t === 'object') {
50
+ valid = value instanceof type;
51
+ }
52
+ }
53
+ else if (expectedType === 'Object') {
54
+ valid = isObject(value);
55
+ }
56
+ else if (expectedType === 'Array') {
57
+ valid = isArray(value);
58
+ }
59
+ else if (expectedType === 'null') {
60
+ valid = value === null;
61
+ }
62
+ else {
63
+ valid = value instanceof type;
64
+ }
65
+ return valid;
66
+ }
67
+
68
+ export { checkType, toRawType }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-02-28 17:56:47
4
+ * @Description: file content
5
+ */
6
+ export default {
7
+ EVENT_EXT: "onEventExt", // QCode Modify
8
+ EVENT_LOAD_START: "onLoadStart",
9
+ EVENT_LOAD: "onLoad",
10
+ EVENT_ERROR: "onError",
11
+ EVENT_PROGRESS: "onProgress",
12
+ EVENT_END: "onEnd",
13
+ EVENT_PAUSE: "onPause",
14
+ EVENT_PLAY: "onPlay",
15
+ EVENT_AUDIO_FOCUS_GAIN: "onAudioFocusGain",
16
+ EVENT_AUDIO_FOCUS_LOSS: "onAudioFocusLoss",
17
+ }
@@ -0,0 +1,176 @@
1
+ <script>
2
+ import { sAudioManager } from "./AudioProxy.js";
3
+
4
+ export default {
5
+ props: {
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 {};
38
+ },
39
+ },
40
+ /**
41
+ * 回调函数,播放错误时通过此接口通知。
42
+ * @param {int} 错误类型,当前定义了四种错误。1是异常中断;2是网络错误;3是解码错误;4是格式不支持。
43
+ */
44
+ onError: {
45
+ type: Function,
46
+ default: () => {
47
+ return {};
48
+ },
49
+ },
50
+ /**
51
+ * 回调函数,开始加载,设置完播放地址后,上报此事件。
52
+ */
53
+ onLoadStart: {
54
+ type: Function,
55
+ default: () => {
56
+ return {};
57
+ },
58
+ },
59
+ /**
60
+ * 回调函数,视频准备好后触发。
61
+ */
62
+ onLoadedMetaData: {
63
+ type: Function,
64
+ default: () => {
65
+ return {};
66
+ },
67
+ },
68
+ /**
69
+ * 回调函数,视频准备好后触发,这个时候可以正常seek。
70
+ */
71
+ onLoad: {
72
+ type: Function,
73
+ default: () => {
74
+ return {};
75
+ },
76
+ },
77
+ /**
78
+ * 回调函数,音频失去焦点后触发此事件,可能会导致pause(点播)或者离开频道(直播)。
79
+ */
80
+ onAudioFocusLoss: {
81
+ type: Function,
82
+ default: () => {
83
+ return {};
84
+ },
85
+ },
86
+ /**
87
+ * 回调函数,音频获取焦点后触发此事件,可能会触发resume(点播)或者加入频道(直播)。
88
+ */
89
+ onAudioFocusGain: {
90
+ type: Function,
91
+ default: () => {
92
+ return {};
93
+ },
94
+ },
95
+ /**
96
+ * 属性,Boolean类型,活跃状态
97
+ */
98
+ active: { type: Boolean, default: true },
99
+ },
100
+
101
+ watch: {
102
+ active(newValue) {
103
+ console.log("active newValue: " + newValue);
104
+ if (this.audio) {
105
+ if (newValue) {
106
+ //同key的player切换时需要切换回调
107
+ this.registerEvent();
108
+ }
109
+ }
110
+ },
111
+ },
112
+ setup() {
113
+ return {
114
+ audio: null,
115
+ };
116
+ },
117
+ mounted() {
118
+ let key = "JsvAudio_" + Math.floor(Math.random() * 10000);
119
+ if (this.playerKey) {
120
+ key = this.playerKey;
121
+ }
122
+ console.log("player key:" + key);
123
+
124
+ this.audio = sAudioManager.createAudio(key);
125
+
126
+ if (this.active) {
127
+ this.registerEvent();
128
+ if (this.src && this.src !== "") this.audio.src = this.src;
129
+
130
+ if (this.currentTime !== 0) this.audio.currentTime = this.currentTime;
131
+
132
+ if (this.autoplay) {
133
+ this.audio.autoplay = this.autoplay;
134
+ }
135
+
136
+ if (this.muted) {
137
+ this.audio.muted = this.muted;
138
+ }
139
+
140
+ if (this.loop) {
141
+ this.audio.loop = this.loop;
142
+ }
143
+ }
144
+
145
+ this.onRef?.(this.audio);
146
+ },
147
+
148
+ beforeUnmount() {
149
+ if (this.audio != null) {
150
+ this.audio.release();
151
+ this.onRef?.(null);
152
+ }
153
+ },
154
+
155
+ methods: {
156
+ registerEvent() {
157
+ if (this.audio && this.active) {
158
+ this.audio.addEventListener("end", this.onEnded);
159
+ this.audio.addEventListener("error", this.onError);
160
+ this.audio.addEventListener("loadstart", () => {
161
+ console.log("JsAudio received loadstart event.");
162
+ this.onLoadStart();
163
+ });
164
+ this.audio.addEventListener("loadedmetadata", this.onLoadedMetaData);
165
+ this.audio.addEventListener("load", this.onLoad);
166
+ this.audio.addEventListener("audiofocusloss", this.onAudioFocusLoss);
167
+ this.audio.addEventListener("audiofocusgain", this.onAudioFocusGain);
168
+ }
169
+ },
170
+ },
171
+ };
172
+ </script>
173
+
174
+ <template>
175
+ <div :style="{width: 1, height: 1}" backgroundColor="rgba(0,0,0,1)"></div>
176
+ </template>
@@ -0,0 +1,40 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-02-23 10:06:08
4
+ * @Description: file content
5
+ */
6
+ export default class {
7
+ static isReady() {
8
+ return typeof window.jsvAudioBridge != "undefined" && !!window.jsvAudioBridge;
9
+ }
10
+ static CreateAudio(key, callback) {
11
+ if (typeof window.jsvAudioBridge != "undefined"
12
+ && typeof window.jsvAudioBridge.CreateAudio != "undefined") {
13
+ return window.jsvAudioBridge.CreateAudio(key, callback);
14
+ }
15
+ return -1;
16
+ }
17
+
18
+ static ReleasePlayer(key) {
19
+ if (typeof window.jsvAudioBridge != "undefined"
20
+ && typeof window.jsvAudioBridge.ReleasePlayer != "undefined") {
21
+ return window.jsvAudioBridge.ReleasePlayer(key);
22
+ }
23
+ return -1;
24
+ }
25
+
26
+ static GetProperty(key, name) {
27
+ if (typeof window.jsvAudioBridge != "undefined"
28
+ && typeof window.jsvAudioBridge.GetProperty != "undefined") {
29
+ return window.jsvAudioBridge.GetProperty(key, name);
30
+ }
31
+ return null;
32
+ }
33
+
34
+ static SetProperty(key, params) {
35
+ if (typeof window.jsvAudioBridge != "undefined"
36
+ && typeof window.jsvAudioBridge.SetProperty != "undefined") {
37
+ return window.jsvAudioBridge.SetProperty(key, params);
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,46 @@
1
+ <script>
2
+ // import playerExMethods from "./JsvMediaBrowserInterface.js"
3
+
4
+ export default {
5
+ props: {
6
+ onRef: { type: Function, default: () => {} },
7
+ },
8
+ setup() {
9
+ return {
10
+ audioRef: null,
11
+ };
12
+ },
13
+ methods: {
14
+ onRefProxy(video_ref) {
15
+ this.audioRef = video_ref;
16
+
17
+ // 不在此直接回调 onRef,因为onRefProxy可能会因为 .src的设置导致重新触发一次调用(vue本身问题)
18
+ // 参照vue-core处理的 componentUpdateFn处理, onMounted 一次, src设置后会再次 onPatch 一次
19
+ },
20
+ },
21
+ mounted() {
22
+ if (this.audioRef && this.onRef) {
23
+ let video_ref = this.audioRef;
24
+ this.audioRef = null;
25
+
26
+ // 补充插件扩展出来的接口
27
+ // for (let method_name in playerExMethods) {
28
+ // video_ref[method_name] = playerExMethods[method_name].bind(video_ref);
29
+ // }
30
+
31
+ // 将修改好的video回调返回给使用者
32
+ this.onRef(video_ref);
33
+ }
34
+ },
35
+ beforeUnmount() {
36
+ if (this.onRef) {
37
+ // video_ref为null,代表video标签卸载处理
38
+ this.onRef(null);
39
+ }
40
+ },
41
+ };
42
+ </script>
43
+
44
+ <template>
45
+ <audio :ref="onRefProxy" v-bind="$attrs" />
46
+ </template>