@shijiu/jsview-vue 0.9.684 → 0.9.766

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 (113) 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 +43 -8
  21. package/samples/DemoHomepage/router.js +13 -10
  22. package/samples/DemoHomepage/views/Homepage.vue +83 -96
  23. package/samples/FilterDemo/App.vue +1 -1
  24. package/samples/FlipCard/App.vue +2 -2
  25. package/samples/FlipCard/FlipCard.vue +3 -3
  26. package/samples/GridDemo/App.vue +3 -3
  27. package/samples/GridDemo/ButtonBlock.vue +2 -2
  28. package/samples/GridDemo/FocusItem.vue +2 -2
  29. package/samples/GridDemo/Item.vue +1 -1
  30. package/samples/HashHistory/App.vue +10 -3
  31. package/samples/HashHistory/components/Item.vue +1 -1
  32. package/samples/ImpactStop/App.vue +15 -11
  33. package/samples/Input/InputPanel.vue +1 -1
  34. package/samples/LongImage/Button.vue +1 -1
  35. package/samples/LongImage/ButtonItem.vue +1 -1
  36. package/samples/LongImage/LongImageScroll.vue +2 -2
  37. package/samples/LongText/App.vue +1 -1
  38. package/samples/LongText/Button.vue +1 -1
  39. package/samples/LongText/ButtonItem.vue +1 -1
  40. package/samples/LongText/LongTextScroll.vue +3 -3
  41. package/samples/Marquee/longText.js +2 -2
  42. package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +4 -4
  43. package/samples/MetroWidgetDemos/Advanced/widgets/Item.vue +3 -4
  44. package/samples/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +2 -3
  45. package/samples/MetroWidgetDemos/Advanced/widgets/Widgets.vue +1 -1
  46. package/samples/MetroWidgetDemos/Item.vue +3 -19
  47. package/samples/MetroWidgetDemos/PerformanceTest/App.vue +4 -4
  48. package/samples/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +1 -1
  49. package/samples/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +3 -3
  50. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +2 -2
  51. package/samples/MetroWidgetDemos/PingPong/TabItem.vue +1 -1
  52. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +3 -3
  53. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +2 -2
  54. package/samples/MetroWidgetDemos/WidgetItem.vue +2 -3
  55. package/samples/NinePatchDemo/App.vue +2 -2
  56. package/samples/NinePatchDemo/Item.vue +2 -2
  57. package/samples/Preload/App.vue +1 -1
  58. package/samples/Preload/Item.vue +1 -1
  59. package/samples/QrcodeDemo/App.vue +1 -1
  60. package/samples/SoundPool/App.vue +3 -3
  61. package/samples/SpriteImage/App.vue +5 -0
  62. package/samples/TextBox/App.vue +2 -1
  63. package/samples/TextureAnimation/App2.vue +1 -1
  64. package/samples/ThrowMoveDemo/LRParabolicDemo.vue +33 -47
  65. package/samples/TouchSample/MetroWidgetHorizontal.vue +1 -1
  66. package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
  67. package/samples/TransitPage/App.vue +1 -1
  68. package/samples/VideoDemo/App.vue +8 -8
  69. package/samples/VideoDemo/components/Button.vue +1 -1
  70. package/samples/VideoDemo/components/Controllor.vue +1 -1
  71. package/samples/VisibleSensorDemo/App.vue +3 -3
  72. package/scripts/jsview-run-android.js +5 -4
  73. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +4 -4
  74. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +65 -39
  75. package/utils/JsViewEngineWidget/TemplateParser.js +138 -146
  76. package/utils/JsViewEngineWidget/WidgetCommon.js +12 -3
  77. package/utils/JsViewPlugin/BrowserPluginLoader.js +4 -2
  78. package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +302 -0
  79. package/utils/JsViewPlugin/JsvAudio/CheckType.js +68 -0
  80. package/utils/JsViewPlugin/JsvAudio/Events.js +17 -0
  81. package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +176 -0
  82. package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +40 -0
  83. package/utils/JsViewPlugin/JsvAudio/JsvAudioBrowser.vue +46 -0
  84. package/utils/JsViewPlugin/JsvAudio/PluginLoader.js +140 -0
  85. package/utils/JsViewPlugin/JsvAudio/index.js +26 -0
  86. package/utils/JsViewPlugin/JsvAudio/version.js +24 -0
  87. package/utils/JsViewPlugin/JsvPlayer/index.js +1 -1
  88. package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
  89. package/utils/JsViewVueTools/JsvHashHistory.js +34 -8
  90. package/utils/JsViewVueTools/JsvImpactTracer.js +2 -2
  91. package/utils/JsViewVueTools/JsvRuntimeBridge.js +46 -8
  92. package/utils/JsViewVueTools/JsvStyleClass.js +9 -0
  93. package/utils/{JsViewVueWidget/utils/text.js → JsViewVueTools/JsvTextTools.js} +3 -4
  94. package/utils/JsViewVueTools/TypeCheckAndSet.js +3 -3
  95. package/utils/JsViewVueTools/index.js +2 -1
  96. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +5 -7
  97. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +20 -22
  98. package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +4 -4
  99. package/utils/JsViewVueWidget/JsvGrid.vue +1 -9
  100. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +1 -1
  101. package/utils/JsViewVueWidget/JsvMarquee.vue +22 -12
  102. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +1 -1
  103. package/utils/JsViewVueWidget/JsvNinePatch.vue +63 -53
  104. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +10 -5
  105. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +2 -2
  106. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +3 -3
  107. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +1 -1
  108. package/utils/JsViewVueWidget/JsvTextBox.vue +11 -31
  109. package/utils/JsViewVueWidget/JsvTouchContainer.vue +2 -2
  110. package/utils/JsViewVueWidget/JsvTransparentDiv.vue +1 -1
  111. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +5 -5
  112. package/utils/JsViewVueWidget/index.js +8 -8
  113. package/utils/JsViewVueWidget/utils/index.js +0 -8
@@ -2,7 +2,7 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2020-12-30 14:08:38
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-11-09 09:33:15
5
+ * @LastEditTime: 2022-12-01 16:49:21
6
6
  * @Description: file content
7
7
  */
8
8
  class BaseDispatcher {
@@ -84,7 +84,7 @@ function getPositionRelativeToView(divElement, targetElement) {
84
84
  while (element && element !== targetElement) {
85
85
  position.left += element.style.left ? element.style.left : 0;
86
86
  position.top += element.style.top ? element.style.top : 0;
87
- element = element.parentElement;
87
+ element = element.parentNode;
88
88
  }
89
89
  return position;
90
90
  }
@@ -174,7 +174,7 @@ class SeamlessSlide extends SlideSetting {
174
174
  **/
175
175
  class FixPositionSlide extends SlideSetting {
176
176
  constructor({
177
- fixPercent,
177
+ fixPercent = .5,
178
178
  speed = defaultSpeed,
179
179
  easing = defaultEasing,
180
180
  boundaryProtect = SlideSetting.START_PROTECT | SlideSetting.END_PROTECT,
@@ -184,6 +184,14 @@ class FixPositionSlide extends SlideSetting {
184
184
  }
185
185
  }
186
186
 
187
+ const FocusMoveType = {
188
+ NO_ADJUST: 0x00000000,
189
+ COLUMN_LOOP: 0x00000001,
190
+ ROW_LOOP: 0x00000001 << 1,
191
+ COLUMN_FIND_NEAR: 0x00000001 << 2,
192
+ ROW_FIND_NEAR: 0x00000001 << 3,
193
+ };
194
+
187
195
  // randomColor() {
188
196
  // let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
189
197
  // return (
@@ -203,4 +211,5 @@ export {
203
211
  WholePageSlide,
204
212
  SeamlessSlide,
205
213
  FixPositionSlide,
214
+ FocusMoveType,
206
215
  };
@@ -1,14 +1,16 @@
1
1
  /*
2
2
  * @Author: LuDonglin
3
3
  * @Date: 2022-2-24 14:00:00
4
- * @LastEditors: LuDonglin
5
- * @LastEditTime: 2022-2-24 14:00:00
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2023-03-02 10:56:24
6
6
  * @Description: file content
7
7
  */
8
8
  import { JsvWidgetWrapperGroup } from 'jsview/utils/JsViewVueWidget/BrowserDebugWidget/WidgetWrapper.js';
9
9
  //考虑到.vue文件除了export default的component外,还有可能export其他对象,因此使用import * as
10
10
  import * as BrowserJsvPlayer from "./JsvPlayer/JsvPlayerBrowser.vue";
11
+ import * as BrowserJsvAudio from "./JsvAudio/JsvAudioBrowser.vue";
11
12
 
12
13
  JsvWidgetWrapperGroup.BrowserJsvPlayer = BrowserJsvPlayer;
14
+ JsvWidgetWrapperGroup.BrowserJsvAudio = BrowserJsvAudio;
13
15
 
14
16
  console.log("load browser plugin widgets.");
@@ -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
+ }