Commit 3e12b4fb authored by liujiangnan's avatar liujiangnan

feat: 循环播放

parent d0ae7c80
......@@ -100,18 +100,21 @@
},
{
"__id__": 112
},
{
"__id__": 114
}
],
"_active": true,
"_components": [
{
"__id__": 114
"__id__": 116
},
{
"__id__": 115
"__id__": 117
},
{
"__id__": 116
"__id__": 118
}
],
"_prefab": null,
......@@ -2045,7 +2048,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-135,
-153.885,
-3.5,
0,
0,
......@@ -2259,7 +2262,7 @@
"alignMode": 1,
"_target": null,
"_alignFlags": 8,
"_left": -180.5,
"_left": -199.385,
"_right": 0,
"_top": 0,
"_bottom": 0,
......@@ -2319,7 +2322,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-135.692,
-156.937,
-4.481,
0,
0,
......@@ -2533,7 +2536,7 @@
"alignMode": 1,
"_target": null,
"_alignFlags": 8,
"_left": -181.192,
"_left": -202.437,
"_right": 0,
"_top": 0,
"_bottom": 0,
......@@ -3125,8 +3128,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
537.028,
-2.992,
555.95,
-8.672,
0,
0,
0,
......@@ -3194,7 +3197,7 @@
"_target": null,
"_alignFlags": 32,
"_left": 0,
"_right": 64.97199999999998,
"_right": 46.049999999999955,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
......@@ -5112,8 +5115,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-300.398,
192.721,
-349.97,
270.168,
0,
0,
0,
......@@ -5169,6 +5172,108 @@
"_atlas": null,
"_id": "4eSLHdRBRFyp08vEy+C7J3"
},
{
"__type__": "cc.Node",
"_name": "loading",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 115
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 279,
"height": 180
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
332.841,
44.851,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d0ZMTg0rxKCaL+r+EyWAkJ"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "Armature",
"_animationName": "ufo",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": 0,
"premultipliedAlpha": false,
"_armatureKey": "288acd69-22c1-4220-a10c-2478978214fa#65279454-8940-4cc5-aebb-41989f70e57f",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "288acd69-22c1-4220-a10c-2478978214fa"
},
"_N$dragonAtlasAsset": {
"__uuid__": "65279454-8940-4cc5-aebb-41989f70e57f"
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "85pbnJ3DhOO5vkZVP5GeAa"
},
{
"__type__": "cc.Canvas",
"_name": "",
......
......@@ -143,6 +143,7 @@ cc.Class({
// use this for initialization
_isPlayComplated: null,
_isReadyToPlay: null,
onLoad () {
cc.debug.setDisplayStats(false);
......@@ -160,8 +161,10 @@ cc.Class({
this.videoPlayer.node.on('meta-loaded', () => {
console.log('meta-loaded');
cc.find(`Canvas/bg_video_shadow`).active = false;
this._isReadyToPlay = true;
cc.find(`Canvas/loading`).active = false;
this.durationLabel.string = this.formatTime(this.videoPlayer.getDuration());
this._isReadyToPlay = true;
this._isPlayComplated = false;
this.videoPlayer.currentTime = 0;
// this.videoPlayer.resume();
this.play();
......@@ -217,7 +220,15 @@ cc.Class({
this._isPlayComplated = true;
this.playButton.node.active = false;
this.pauseButton.node.active = false;
this.restartButton.node.active = true;
this.restartButton.node.active = false;
// 循环播放下一个
const nextItem = this.videoItemList[this.videoPlayIndex + 1];
if(nextItem) {
nextItem.emit('my_item_click');
} else {
this.videoItemList[0].emit('my_item_click');
}
});
cc.view.setResizeCallback((params) => {
console.log('Resize', params);
......@@ -272,7 +283,11 @@ cc.Class({
this.updateBarByPos(this.barTag.x);
});
},
videoItemList: null,
videoPlayIndex: null,
async initView() {
this.videoItemList = [];
const videoListContent = cc.find(`Canvas/videolist/view/content`);
const templateItem = cc.find(`item`, videoListContent);
for (let i = 0; i < this.data.dataArr.length; i++) {
......@@ -293,7 +308,12 @@ cc.Class({
cc.find(`item_active/num`, itemClone).getComponent(cc.Label).string = (i+1>9?(i+1):`0${i+1}`);
cc.find(`item/num`, itemClone).getComponent(cc.Label).string = (i+1>9?(i+1):`0${i+1}`);
itemClone.attr({video_url: row.video_url});
itemClone.attr({video_url: row.video_url, playIndex: i});
itemClone.on('my_item_click', () => {
// 无法用代码触发click事件,所以只能写一个自定义事件了
this.clickVideoItem(null, itemClone);
});
this.videoItemList.push(itemClone);
}
},
......@@ -306,8 +326,8 @@ cc.Class({
}
},
// 选择视频播放
async clickVideoItem(evt) {
const item = evt.currentTarget;
async clickVideoItem(evt, _node) {
const item = evt?evt.currentTarget:_node;
if (!item.video_url) {
this.showTips("视频不存在");
return;
......@@ -316,7 +336,9 @@ cc.Class({
this.showTips("该视频正在播放");
return;
}
this.videoPlayIndex = item.playIndex;
this._isReadyToPlay = false;
cc.find(`Canvas/loading`).active = true;
cc.find(`Canvas/bg`).active = true;
cc.find(`Canvas/bgwhite`).active = true;
cc.find(`Canvas/bg_video_shadow`).active = true;
......
{"name":"loading","version":"5.5","armature":[{"name":"Armature","ik":[],"bone":[{"name":"root","transform":{}},{"name":"组_1","transform":{"x":2.05,"skY":-90,"y":40.15,"skX":-90},"length":65,"parent":"root"},{"name":"A","transform":{"x":74.1475,"skY":90,"y":-2.05,"skX":90},"parent":"组_1"}],"aabb":{"x":-139.5,"height":180,"y":-90,"width":279},"defaultActions":[{"gotoAndPlay":"ufo"}],"animation":[{"name":"ufo","frame":[],"bone":[{"name":"root","rotateFrame":[],"translateFrame":[],"scaleFrame":[]},{"name":"组_1","rotateFrame":[{"duration":15,"rotate":8.3771,"curve":[0,0,0.5,1]},{"duration":15,"rotate":10.9763,"tweenEasing":0},{"duration":0,"rotate":8.3771}],"translateFrame":[{"curve":[0,0,0.5,1],"duration":15},{"tweenEasing":0,"y":13.0573,"duration":15},{"duration":0}],"scaleFrame":[]},{"name":"A","rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"rotate":-9.1133,"tweenEasing":0},{"duration":10,"rotate":-13.9913,"tweenEasing":0},{"duration":0}],"translateFrame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"x":-6.4977,"y":1.2205,"duration":10},{"tweenEasing":0,"x":4.0509,"y":-0.6604,"duration":10},{"duration":0}],"scaleFrame":[]}],"playTimes":0,"ffd":[],"slot":[{"name":"组_1","displayFrame":[],"colorFrame":[]},{"name":"A","displayFrame":[{"duration":10},{"duration":10,"value":1},{"duration":10,"value":2},{"duration":0}],"colorFrame":[]}],"ik":[],"duration":30}],"slot":[{"name":"组_1","color":{},"parent":"组_1"},{"name":"A","color":{},"z":1,"parent":"A"}],"skin":[{"name":"","slot":[{"name":"A","display":[{"name":"ufo/A","transform":{"skY":-0.0263,"y":-1.0025,"skX":-0.0263},"type":"image","path":"ufo/A"},{"name":"ufo/B","transform":{"x":4.5,"skY":-0.0263,"y":-1.0025,"skX":-0.0263},"type":"image","path":"ufo/B"},{"name":"ufo/C","transform":{"x":-4.5,"skY":-0.0263,"y":-0.5025,"skX":-0.0263},"type":"image","path":"ufo/C"}]},{"name":"组_1","display":[{"name":"ufo/组_1","transform":{"x":40.15,"skY":89.9737,"y":-2.05,"skX":89.9737},"type":"image","path":"ufo/组_1"}]}]}],"frameRate":24,"type":"Armature"}],"frameRate":24,"isGlobal":0}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "288acd69-22c1-4220-a10c-2478978214fa",
"subMetas": {}
}
\ No newline at end of file
{"name":"loading","imagePath":"loading_tex.png","SubTexture":[{"name":"ufo/组_1","x":1,"height":180,"y":1,"width":279},{"name":"ufo/A","x":282,"height":80,"y":1,"width":83},{"name":"ufo/B","x":282,"height":80,"y":83,"width":60},{"name":"ufo/C","x":367,"height":83,"y":1,"width":58}],"height":256,"width":512}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "65279454-8940-4cc5-aebb-41989f70e57f",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f2d76ff5-c16f-4361-9362-661c20800248",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 256,
"platformSettings": {},
"subMetas": {
"loading_tex": {
"ver": "1.0.4",
"uuid": "c8e21a8a-5f7f-4a9c-a0ba-4fefc26d652f",
"rawTextureUuid": "f2d76ff5-c16f-4361-9362-661c20800248",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -43,
"offsetY": 37,
"trimX": 1,
"trimY": 1,
"width": 424,
"height": 180,
"rawWidth": 512,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment