@cc-component/cc-video 1.2.2 → 1.2.4
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/assets/video/VideoComponent.prefab +4 -3
- package/assets/video/base/IVideo.ts +2 -0
- package/assets/video/base/VideoManager.ts +8 -2
- package/assets/video/base/VideoModule.ts +8 -0
- package/assets/video/base/VideoPlayTT.ts +9 -11
- package/assets/video/base/VideoPlayWeb.ts +8 -5
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"_lpos": {
|
|
47
47
|
"__type__": "cc.Vec3",
|
|
48
48
|
"x": -540,
|
|
49
|
-
"y": 960,
|
|
49
|
+
"y": 960.0000000000001,
|
|
50
50
|
"z": 0
|
|
51
51
|
},
|
|
52
52
|
"_lrot": {
|
|
@@ -528,7 +528,7 @@
|
|
|
528
528
|
"_contentSize": {
|
|
529
529
|
"__type__": "cc.Size",
|
|
530
530
|
"width": 1080,
|
|
531
|
-
"height": 1920
|
|
531
|
+
"height": 1920.0000000000002
|
|
532
532
|
},
|
|
533
533
|
"_anchorPoint": {
|
|
534
534
|
"__type__": "cc.Vec2",
|
|
@@ -589,10 +589,11 @@
|
|
|
589
589
|
"__prefab": {
|
|
590
590
|
"__id__": 27
|
|
591
591
|
},
|
|
592
|
+
"des": "项目设置-宏配置-ENABLE_TRANSPARENT_CANVAS,开启透明画布",
|
|
592
593
|
"bundle_name": "video",
|
|
593
594
|
"video_dir": "video_dir",
|
|
594
595
|
"cover_dir": "cover_dir",
|
|
595
|
-
"remote_url": "https://hcy-cdn-domestic.wyx.cn/online/comeback/",
|
|
596
|
+
"remote_url": "https://hcy-cdn-domestic.wyx.cn/online/comeback/video_dy/",
|
|
596
597
|
"_id": ""
|
|
597
598
|
},
|
|
598
599
|
{
|
|
@@ -119,6 +119,7 @@ export class VideoManager {
|
|
|
119
119
|
this.baseVideo.onError = (err) => {
|
|
120
120
|
this.isError = true;
|
|
121
121
|
console.error("视频报错了 ", err)
|
|
122
|
+
this.param.onError?.()
|
|
122
123
|
};
|
|
123
124
|
|
|
124
125
|
this.baseVideo.onVideoEnd = () => {
|
|
@@ -215,11 +216,16 @@ export class VideoManager {
|
|
|
215
216
|
// console.log('加载视频', name)
|
|
216
217
|
const isloop = false
|
|
217
218
|
const onRead = param.onRead
|
|
219
|
+
const onError = param.onError
|
|
220
|
+
|
|
218
221
|
param.onRead = () => {
|
|
219
222
|
console.warn('当前播放', name)
|
|
220
223
|
onRead?.()
|
|
221
224
|
this.playVideo(param)
|
|
222
225
|
}
|
|
226
|
+
param.onError = () => {
|
|
227
|
+
onError?.()
|
|
228
|
+
}
|
|
223
229
|
this.loadVideo(name, param)
|
|
224
230
|
}
|
|
225
231
|
|
|
@@ -268,8 +274,8 @@ export class VideoManager {
|
|
|
268
274
|
// 清理任务
|
|
269
275
|
if (VideoManager.instance.Debug)
|
|
270
276
|
console.log('任务已结束', oldTask?.count);
|
|
271
|
-
if (!param.isLoop)
|
|
272
|
-
|
|
277
|
+
// if (!param.isLoop && !this.stopRequested)
|
|
278
|
+
// param.onFinish?.()
|
|
273
279
|
//this.playTasks.delete(taskId);
|
|
274
280
|
});
|
|
275
281
|
}
|
|
@@ -72,10 +72,14 @@ export class VideoModule {
|
|
|
72
72
|
if (param.isLocal === undefined)
|
|
73
73
|
param.isLocal = VideoModule.isLocal(video.name)
|
|
74
74
|
const onRead = param.onRead
|
|
75
|
+
const onError = param.onError
|
|
75
76
|
param.onRead = () => {
|
|
76
77
|
onRead?.()
|
|
77
78
|
VideoManager.instance.playVideo(param)
|
|
78
79
|
}
|
|
80
|
+
param.onError = () => {
|
|
81
|
+
onError?.()
|
|
82
|
+
}
|
|
79
83
|
VideoManager.instance.loadVideo(video.name, param)
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -87,10 +91,14 @@ export class VideoModule {
|
|
|
87
91
|
|
|
88
92
|
if (param.isPlayTime) {
|
|
89
93
|
const onRead = param.onRead
|
|
94
|
+
const onError = param.onError
|
|
90
95
|
param.onRead = () => {
|
|
91
96
|
onRead?.()
|
|
92
97
|
VideoManager.instance.playVideoList(video_list, param)
|
|
93
98
|
}
|
|
99
|
+
param.onError = () => {
|
|
100
|
+
onError?.()
|
|
101
|
+
}
|
|
94
102
|
VideoManager.instance.loadVideo(url, param)
|
|
95
103
|
} else {
|
|
96
104
|
VideoManager.instance.playVideoList(video_list, param)
|
|
@@ -96,13 +96,12 @@ export class VideoPlayTT extends BaseVideo {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
onCanplay() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.warn('准备好了')
|
|
99
|
+
|
|
100
|
+
if (!this.canPlay) {
|
|
101
|
+
if (VideoModule.IsDebug())
|
|
102
|
+
console.warn('准备好了')
|
|
103
|
+
}
|
|
104
|
+
|
|
106
105
|
this.videoTexture = new Texture2D();
|
|
107
106
|
this.imgAsset.reset(this.videoPlayer);
|
|
108
107
|
this.videoTexture.image = this.imgAsset;
|
|
@@ -128,9 +127,8 @@ export class VideoPlayTT extends BaseVideo {
|
|
|
128
127
|
this.videoPlayer = this.createVideoWX(name, true)
|
|
129
128
|
this.actioveSelf(true)
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
this.videoPlayer.src = name;
|
|
133
130
|
this.videoPlayer.onCanplay(this.onCanplay.bind(this))
|
|
131
|
+
this.videoPlayer.src = name;
|
|
134
132
|
|
|
135
133
|
this.videoPlayer.loop = param.isLoop
|
|
136
134
|
const is_skip = name === this.remoteURL;
|
|
@@ -262,7 +260,7 @@ export class VideoPlayTT extends BaseVideo {
|
|
|
262
260
|
async destroyVideo() {
|
|
263
261
|
if (this.videoPlayer) {
|
|
264
262
|
|
|
265
|
-
|
|
263
|
+
this.canPlay = false
|
|
266
264
|
this.is_stop = true
|
|
267
265
|
this.actioveSelf(false)
|
|
268
266
|
this.video_sp.spriteFrame = null
|
|
@@ -300,7 +298,7 @@ export class VideoPlayTT extends BaseVideo {
|
|
|
300
298
|
var y = param.y - size.height + param.height / 2 * ratio //* ratio// + param.height / 2 * ratio
|
|
301
299
|
this.video_sp_ut.node.position = new Vec3(x, y, 0);
|
|
302
300
|
this.video_sp_ut.contentSize = new Size(width, height);
|
|
303
|
-
console.error(param.y, size)
|
|
301
|
+
// console.error(param.y, size)
|
|
304
302
|
}
|
|
305
303
|
}
|
|
306
304
|
|
|
@@ -45,9 +45,10 @@ export class VideoPlayWeb extends BaseVideo {
|
|
|
45
45
|
this.videoPlayer = comp
|
|
46
46
|
comp.enabled = true
|
|
47
47
|
// node.on(VideoPlayer.EventType.READY_TO_PLAY, this.readyPlay, this);
|
|
48
|
-
node.on(VideoPlayer.EventType.PLAYING, this.playIng
|
|
49
|
-
node.on(VideoPlayer.EventType.COMPLETED, this.videoEnd
|
|
50
|
-
node.on(VideoPlayer.EventType.ERROR, this.videoError
|
|
48
|
+
node.on(VideoPlayer.EventType.PLAYING, this.playIng, this);
|
|
49
|
+
node.on(VideoPlayer.EventType.COMPLETED, this.videoEnd, this);
|
|
50
|
+
node.on(VideoPlayer.EventType.ERROR, this.videoError, this);
|
|
51
|
+
console.error(node)
|
|
51
52
|
|
|
52
53
|
comp.resourceType = VideoPlayer.ResourceType.REMOTE;
|
|
53
54
|
comp.stayOnBottom = true;
|
|
@@ -78,6 +79,7 @@ export class VideoPlayWeb extends BaseVideo {
|
|
|
78
79
|
this.activeVideo(true)
|
|
79
80
|
if (!param.isTargetSize)
|
|
80
81
|
this.autoSize()
|
|
82
|
+
this.videoPlayer.clip = null
|
|
81
83
|
this.videoPlayer.clip = clip;
|
|
82
84
|
//this.videoPlayer.remoteURL = "";
|
|
83
85
|
this.videoPlayer.loop = param.isLoop
|
|
@@ -97,14 +99,15 @@ export class VideoPlayWeb extends BaseVideo {
|
|
|
97
99
|
if (!param.isTargetSize)
|
|
98
100
|
this.autoSize()
|
|
99
101
|
const is_skip = name === this.videoPlayer.remoteURL;
|
|
102
|
+
this.videoPlayer.remoteURL = ""
|
|
100
103
|
this.videoPlayer.remoteURL = name;
|
|
101
104
|
this.videoPlayer.resourceType = VideoPlayer.ResourceType.REMOTE;
|
|
102
105
|
this.videoPlayer.loop = param.isLoop
|
|
103
|
-
|
|
104
106
|
//console.warn('暂停', is_skip)
|
|
105
107
|
if (is_skip) {
|
|
106
108
|
this.isReady = true;
|
|
107
109
|
this.readyPlay()
|
|
110
|
+
//this.play()
|
|
108
111
|
} else {
|
|
109
112
|
this.play()
|
|
110
113
|
//this.pause();
|
|
@@ -160,7 +163,7 @@ export class VideoPlayWeb extends BaseVideo {
|
|
|
160
163
|
// if (!this.isloop) this.node.off(VideoPlayer.EventType.READY_TO_PLAY, this.readyPlay, this);
|
|
161
164
|
this.onRead?.(this)
|
|
162
165
|
}
|
|
163
|
-
private videoError() {
|
|
166
|
+
private videoError(error: any) {
|
|
164
167
|
this.onError?.();
|
|
165
168
|
}
|
|
166
169
|
|