@cc-component/cc-ex-component 1.1.5 → 1.1.7
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/core/BaseReference.ts +40 -0
- package/assets/{video/Interface.ts.meta → core/BaseReference.ts.meta} +1 -1
- package/assets/core/BaseViewModelData.ts +12 -0
- package/assets/{video/VideoComponent.ts.meta → core/BaseViewModelData.ts.meta} +1 -1
- package/assets/core/ReferenceComponent.ts +317 -0
- package/assets/core/ViewModel.ts +542 -0
- package/assets/core/ViewModel.ts.meta +9 -0
- package/assets/ex/EXButton.ts +191 -0
- package/assets/ex/EXButton.ts.meta +9 -0
- package/assets/ex/{BaseEx.ts → ExCommon.ts} +6 -4
- package/assets/ex/ExTool.ts +116 -0
- package/assets/ex/ExTool.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts +105 -0
- package/assets/{video/IVideo.ts.meta → lib/collectView/lib-ext/custom-grid-flow-layout.ts.meta} +1 -1
- package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts +84 -0
- package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts +132 -0
- package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts +156 -0
- package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-cover-layout.ts +405 -0
- package/assets/lib/collectView/lib-ext/yx-cover-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts +194 -0
- package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-page-view.ts +232 -0
- package/assets/lib/collectView/lib-ext/yx-page-view.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext/yx-table-view.ts +159 -0
- package/assets/lib/collectView/lib-ext/yx-table-view.ts.meta +9 -0
- package/assets/lib/collectView/lib-ext.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-collection-view.ts +1549 -0
- package/assets/lib/collectView/lib_collect/yx-collection-view.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts +364 -0
- package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-flow-layout.ts +909 -0
- package/assets/lib/collectView/lib_collect/yx-flow-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect/yx-table-layout.ts +352 -0
- package/assets/lib/collectView/lib_collect/yx-table-layout.ts.meta +9 -0
- package/assets/lib/collectView/lib_collect.meta +9 -0
- package/assets/{video/list.meta → lib/collectView.meta} +9 -9
- package/assets/lib/tableView/IListView.ts +17 -0
- package/assets/lib/tableView/IListView.ts.meta +9 -0
- package/assets/lib/tableView/ListView.ts +197 -0
- package/assets/lib/tableView/ListView.ts.meta +9 -0
- package/assets/lib/tableView/ListViewPage.ts +1048 -0
- package/assets/lib/tableView/ListViewPage.ts.meta +9 -0
- package/assets/lib/tableView/ListViewPageLoop.ts +922 -0
- package/assets/lib/tableView/ListViewPageLoop.ts.meta +1 -0
- package/assets/lib/tableView/TableView.ts +82 -0
- package/assets/lib/tableView/TableView.ts.meta +9 -0
- package/assets/lib/tableView.meta +9 -0
- package/assets/{video.meta → lib.meta} +1 -1
- package/assets/platform/Interface.ts +15 -10
- package/assets/platform/android/AndroidModule.ts +12 -0
- package/assets/platform/android/AndroidModule.ts.meta +9 -0
- package/assets/platform/android/AndroidSDK.ts +12 -2
- package/assets/platform/base/EditorSDK.ts +12 -11
- package/assets/platform/base/PlatfprmModule.ts +44 -29
- package/assets/platform/base/SDKBase.ts +3 -3
- package/assets/platform/base/TTSDK.ts +22 -11
- package/assets/platform/base/WXSDK.ts +16 -17
- package/assets/platform/wx/MiniSDK.ts +41 -3
- package/assets/platform/wx/wxmini.d.ts +2 -2
- package/index.ts +1 -3
- package/package.json +1 -1
- package/assets/core/ReferenceCollector.ts +0 -172
- package/assets/video/IVideo.ts +0 -73
- package/assets/video/Interface.ts +0 -25
- package/assets/video/VideoComponent.prefab +0 -614
- package/assets/video/VideoComponent.prefab.meta +0 -13
- package/assets/video/VideoComponent.ts +0 -33
- package/assets/video/VideoManager.ts +0 -399
- package/assets/video/VideoManager.ts.meta +0 -9
- package/assets/video/VideoModule.ts +0 -137
- package/assets/video/VideoModule.ts.meta +0 -9
- package/assets/video/VideoPlayTT.ts +0 -338
- package/assets/video/VideoPlayTT.ts.meta +0 -9
- package/assets/video/VideoPlayWX.ts +0 -274
- package/assets/video/VideoPlayWX.ts.meta +0 -9
- package/assets/video/VideoPlayWeb.ts +0 -228
- package/assets/video/VideoPlayWeb.ts.meta +0 -9
- /package/assets/core/{ReferenceCollector.ts.meta → ReferenceComponent.ts.meta} +0 -0
- /package/assets/ex/{BaseEx.ts.meta → ExCommon.ts.meta} +0 -0
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { _decorator, assetManager, Component, Node, Size, UITransform, VideoClip, VideoPlayer, view } from 'cc';
|
|
2
|
-
import { BaseVideo, IVideoParam } from './IVideo';
|
|
3
|
-
import { v3 } from 'cc';
|
|
4
|
-
import { sys } from 'cc';
|
|
5
|
-
const { ccclass, property } = _decorator;
|
|
6
|
-
|
|
7
|
-
@ccclass('VideoPlayWeb')
|
|
8
|
-
export class VideoPlayWeb extends BaseVideo {
|
|
9
|
-
|
|
10
|
-
onTimeUpdate: (data: { position: number, duration: number }) => void = null
|
|
11
|
-
onError: Function = null
|
|
12
|
-
onVideoEnd: Function = null
|
|
13
|
-
onRead: Function = null
|
|
14
|
-
data: { position: number, duration: number } = {
|
|
15
|
-
position: 0,
|
|
16
|
-
duration: 0
|
|
17
|
-
}
|
|
18
|
-
videoName: string = ""
|
|
19
|
-
videoPlayer: VideoPlayer
|
|
20
|
-
isPlaying: boolean = false
|
|
21
|
-
|
|
22
|
-
// node: Node;
|
|
23
|
-
taskId: string;
|
|
24
|
-
param: IVideoParam = {
|
|
25
|
-
isLoop: true,
|
|
26
|
-
isLocal: true,
|
|
27
|
-
isPlayTime: false,
|
|
28
|
-
isTargetSize: false
|
|
29
|
-
}
|
|
30
|
-
initParam: { bundle: string, dir: string }
|
|
31
|
-
nodeUT: UITransform;
|
|
32
|
-
isReady: boolean = false;
|
|
33
|
-
|
|
34
|
-
old_x = 0
|
|
35
|
-
getisPause() {
|
|
36
|
-
return !this.isPlaying
|
|
37
|
-
}
|
|
38
|
-
initVideo(initParam: { bundle: string, dir: string }) {
|
|
39
|
-
this.initParam = initParam
|
|
40
|
-
// this.node = node;
|
|
41
|
-
const node = this.node;
|
|
42
|
-
this.old_x = node.position.x
|
|
43
|
-
this.nodeUT = this.node.getComponent(UITransform);
|
|
44
|
-
let comp = node.addComponent(VideoPlayer);
|
|
45
|
-
this.videoPlayer = comp
|
|
46
|
-
comp.enabled = true
|
|
47
|
-
// node.on(VideoPlayer.EventType.READY_TO_PLAY, this.readyPlay, this);
|
|
48
|
-
node.on(VideoPlayer.EventType.PLAYING, this.playIng.bind(this), this);
|
|
49
|
-
node.on(VideoPlayer.EventType.COMPLETED, this.videoEnd.bind(this), this);
|
|
50
|
-
node.on(VideoPlayer.EventType.ERROR, this.videoError.bind(this), this);
|
|
51
|
-
|
|
52
|
-
comp.resourceType = VideoPlayer.ResourceType.REMOTE;
|
|
53
|
-
comp.stayOnBottom = true;
|
|
54
|
-
comp.playOnAwake = true;
|
|
55
|
-
comp.currentTime = 0;
|
|
56
|
-
comp.volume = 1;
|
|
57
|
-
comp.mute = true;
|
|
58
|
-
comp.keepAspectRatio = false;
|
|
59
|
-
//comp.fullScreenOnAwake = true;
|
|
60
|
-
comp.loop = true;
|
|
61
|
-
comp.fullScreenOnAwake = false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public loadVideo(name: string, param: IVideoParam) {
|
|
65
|
-
this.param = param;
|
|
66
|
-
// this.videoPlayer.fullScreenOnAwake = false;
|
|
67
|
-
//this.play()
|
|
68
|
-
|
|
69
|
-
this.isReady = false;
|
|
70
|
-
if (param.isLocal) {
|
|
71
|
-
this.videoPlayer.resourceType = VideoPlayer.ResourceType.LOCAL;
|
|
72
|
-
//this.videoPlayer.clip = assetManager.getBundle(this.initParam.bundle).get(`${this.initParam.dir}/${name}`, VideoClip);
|
|
73
|
-
assetManager.getBundle(this.initParam.bundle).load(`${this.initParam.dir}/${name}`, VideoClip, (err, clip) => {
|
|
74
|
-
if (err) {
|
|
75
|
-
console.error('视频加载失败:');
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.activeVideo(true)
|
|
79
|
-
if (!param.isTargetSize)
|
|
80
|
-
this.autoSize()
|
|
81
|
-
this.videoPlayer.clip = clip;
|
|
82
|
-
//this.videoPlayer.remoteURL = "";
|
|
83
|
-
this.videoPlayer.loop = param.isLoop
|
|
84
|
-
const is_skip = name === this.videoName;
|
|
85
|
-
//console.warn('暂停', is_skip)
|
|
86
|
-
|
|
87
|
-
if (is_skip) {
|
|
88
|
-
this.isReady = true;
|
|
89
|
-
this.readyPlay()
|
|
90
|
-
} else {
|
|
91
|
-
//this.pause();
|
|
92
|
-
}
|
|
93
|
-
this.videoName = name
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
this.activeVideo(true)
|
|
97
|
-
if (!param.isTargetSize)
|
|
98
|
-
this.autoSize()
|
|
99
|
-
const is_skip = name === this.videoPlayer.remoteURL;
|
|
100
|
-
this.videoPlayer.remoteURL = name;
|
|
101
|
-
this.videoPlayer.resourceType = VideoPlayer.ResourceType.REMOTE;
|
|
102
|
-
//console.warn('暂停', is_skip)
|
|
103
|
-
if (is_skip) {
|
|
104
|
-
this.isReady = true;
|
|
105
|
-
this.readyPlay()
|
|
106
|
-
} else {
|
|
107
|
-
this.play()
|
|
108
|
-
//this.pause();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
play(isloop?: boolean) {
|
|
114
|
-
if (isloop != undefined || isloop != null) {
|
|
115
|
-
this.videoPlayer.loop = isloop
|
|
116
|
-
}
|
|
117
|
-
//console.warn("播放2")
|
|
118
|
-
this.videoPlayer.play();
|
|
119
|
-
// this.videoPlayer.resume();
|
|
120
|
-
this.isPlaying = true
|
|
121
|
-
}
|
|
122
|
-
async pause() {
|
|
123
|
-
this.videoPlayer.pause();
|
|
124
|
-
this.isPlaying = false
|
|
125
|
-
console.log("暂停")
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
stop() {
|
|
129
|
-
this.videoPlayer.stop();
|
|
130
|
-
this.isPlaying = false
|
|
131
|
-
console.log("停止")
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
resume() {
|
|
135
|
-
this.videoPlayer.resume();
|
|
136
|
-
this.isPlaying = true
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
seek(time: number) {
|
|
140
|
-
this.videoPlayer.currentTime = time
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private videoEnd() {
|
|
144
|
-
// if (!this.isloop) this.node.off(VideoPlayer.EventType.COMPLETED, this.videoEnd, this);
|
|
145
|
-
this.onVideoEnd?.();
|
|
146
|
-
}
|
|
147
|
-
private playIng() {
|
|
148
|
-
if (!this.isReady) {
|
|
149
|
-
this.readyPlay()
|
|
150
|
-
}
|
|
151
|
-
this.isReady = true;
|
|
152
|
-
}
|
|
153
|
-
private readyPlay() {
|
|
154
|
-
this.videoPlayer.pause()
|
|
155
|
-
this.isPlaying = false;
|
|
156
|
-
|
|
157
|
-
// if (!this.isloop) this.node.off(VideoPlayer.EventType.READY_TO_PLAY, this.readyPlay, this);
|
|
158
|
-
this.onRead?.(this)
|
|
159
|
-
}
|
|
160
|
-
private videoError() {
|
|
161
|
-
this.onError?.();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
protected onDestroy(): void {
|
|
165
|
-
this.node.off(VideoPlayer.EventType.ERROR, this.videoError, this)
|
|
166
|
-
this.node.off(VideoPlayer.EventType.PLAYING, this.playIng, this)
|
|
167
|
-
this.node.off(VideoPlayer.EventType.COMPLETED, this.videoEnd, this)
|
|
168
|
-
// this.node.off(VideoPlayer.EventType.READY_TO_PLAY, this.readyPlay, this)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
protected update(dt: number): void {
|
|
172
|
-
if (this.isPlaying && this.param.isPlayTime) {
|
|
173
|
-
this.data.position = this.videoPlayer.currentTime;
|
|
174
|
-
this.data.duration = this.videoPlayer.duration;
|
|
175
|
-
this.onTimeUpdate?.(this.data)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async destroyVideo() {
|
|
180
|
-
if (this.videoPlayer) {
|
|
181
|
-
this.activeVideo(false)
|
|
182
|
-
this.stop()
|
|
183
|
-
this.isReady = false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
activeVideo(isActive: boolean) {
|
|
187
|
-
if (sys.platform === sys.Platform.DESKTOP_BROWSER) {
|
|
188
|
-
this.videoPlayer.node.active = isActive
|
|
189
|
-
} else {
|
|
190
|
-
this.videoPlayer.node.position = v3(isActive ? this.old_x : 10000, 0, 0)
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
setSize(param: { x: number, y: number, width: number, height: number }) {
|
|
194
|
-
if (this.videoPlayer) {
|
|
195
|
-
this.nodeUT.contentSize = new Size(param.width, param.height)
|
|
196
|
-
this.node.setWorldPosition(param.x - param.width / 2, param.y + param.height / 2, 0)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// 节点位置适配
|
|
200
|
-
autoSize() {
|
|
201
|
-
//const size = { width: 1080, height: 1920 }
|
|
202
|
-
let screenSize = view.getVisibleSize(); // 获取当前屏幕尺寸
|
|
203
|
-
if (this.param.isVideoFit) {
|
|
204
|
-
screenSize = new Size(1080, 1920)
|
|
205
|
-
}
|
|
206
|
-
const designResolutionSize = view.getDesignResolutionSize()
|
|
207
|
-
const w = screenSize.width / designResolutionSize.width
|
|
208
|
-
const h = screenSize.height / designResolutionSize.height
|
|
209
|
-
|
|
210
|
-
// 根据屏幕宽高调整目标节点的位置
|
|
211
|
-
const ratio = h
|
|
212
|
-
const width = designResolutionSize.width * ratio
|
|
213
|
-
const height = designResolutionSize.height * ratio
|
|
214
|
-
const width_w = screenSize.width - width;
|
|
215
|
-
const height_h = screenSize.height - view.getVisibleSize().height;
|
|
216
|
-
|
|
217
|
-
const x = width_w / 2
|
|
218
|
-
let y = 0//-height / 4
|
|
219
|
-
if (this.param.isVideoFit) {
|
|
220
|
-
y = height_h / 2
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
this.nodeUT.contentSize = new Size(width, height)
|
|
224
|
-
this.node.setPosition(x, y, 0)
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
File without changes
|
|
File without changes
|