Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sb_karaoke_cocos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
sb_karaoke_cocos
Commits
c255575c
Commit
c255575c
authored
Dec 20, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Plain Diff
fix: 闪屏处理
parents
0071c42e
dc5babd8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
41 deletions
+86
-41
sb_karaoke_cocos.meta
assets/sb_karaoke_cocos.meta
+1
-15
adapter_sb_karaoke_cocos.js
...os/components/karaoke/scripts/adapter_sb_karaoke_cocos.js
+5
-5
karaoke.js
...ts/sb_karaoke_cocos/components/karaoke/scripts/karaoke.js
+57
-10
sb_karaoke_cocos.fire
assets/sb_karaoke_cocos/scene/sb_karaoke_cocos.fire
+4
-4
sb_karaoke_cocos.js
assets/sb_karaoke_cocos/scene/sb_karaoke_cocos.js
+19
-7
No files found.
assets/sb_karaoke_cocos.meta
View file @
c255575c
{
"ver": "1.1.2",
"uuid": "810c015d-857f-44be-aa35-fcda8b54edb3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
{"ver":"1.1.2","uuid":"810c015d-857f-44be-aa35-fcda8b54edb3","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
assets/sb_karaoke_cocos/components/karaoke/scripts/adapter_sb_karaoke_cocos.js
View file @
c255575c
...
...
@@ -356,19 +356,19 @@ cc.Class({
}
// window.dispatchEvent(new CustomEvent('resize'), true)
// window.dispatchEvent(new cc.Event.EventCustom('resize', true))
});
cc
.
director
.
on
(
'
GAME_VIEW_DISPLAYED
'
,
()
=>
{
}
,
this
);
cc
.
director
.
on
(
'
GAME_VIEW_DISPLAYED
'
,
function
()
{
// this.karaoke.prepare();
});
}
,
this
);
window
.
gg
=
this
this
.
btnGroup
.
children
.
forEach
(
button
=>
{
button
.
actionStatus
=
this
.
BUTTON_STATUS
.
IDLE
;
button
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
(
event
)
=>
{
button
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
function
(
event
)
{
const
btn
=
event
.
currentTarget
;
window
.
bb
=
btn
;
this
.
buttonGroupChange
(
btn
)
// cc.log("This is a callback after the trigger event", event);
})
}
,
this
)
});
;
},
...
...
assets/sb_karaoke_cocos/components/karaoke/scripts/karaoke.js
View file @
c255575c
...
...
@@ -14,6 +14,26 @@ var DISPLAY_MODE = cc.Enum({
const
LINE_BEAKER
=
'
<br/>
'
;
// '\n'
const
SPACE
=
'
'
;
class
MyAudioSource
{
play
(){
this
.
audId
=
cc
.
audioEngine
.
play
(
this
.
clip
,
false
,
1
);
}
stop
(){
cc
.
audioEngine
.
stop
(
this
.
audId
);
}
pause
(){
cc
.
audioEngine
.
pause
(
this
.
audId
);
}
resume
(){
cc
.
audioEngine
.
resume
(
this
.
audId
);
}
getCurrentTime
()
{
cc
.
audioEngine
.
getCurrentTime
(
this
.
audId
);
}
setCurrentTime
(
sec
)
{
cc
.
audioEngine
.
setCurrentTime
(
this
.
audId
,
sec
);
}
}
/**
* 1.添加空节点,设置节点大小,拖入该脚本
...
...
@@ -148,7 +168,7 @@ cc.Class({
window
[
'
kk
'
]
=
this
;
cc
.
director
.
on
(
'
STOP_ALL_AUDIO_sb_karaoke_cocos
'
,
()
=>
{
this
.
pause
();
});
}
,
this
);
},
setPlayInteractivateMode
(
mode
)
{
...
...
@@ -498,7 +518,7 @@ cc.Class({
// this._lrcNextLineTime = this._lrcData[this._lrcLineIndex] ? this._lrcData[this._lrcLineIndex].time : 0;
// return this._remainContent.shift();
// }
if
(
!
time
)
{
if
(
!
time
||
time
<
0
)
{
time
=
0
;
}
let
idx
=
0
;
...
...
@@ -592,12 +612,12 @@ cc.Class({
let
endIndex
=
nextLineObj
.
index
;
while
(
line
=
this
.
_lrcData
[
endIndex
])
{
if
(
line
.
newLine
||
index
===
0
)
{
return
line
.
time
return
line
.
time
>
0
?
line
.
time
:
0
}
endIndex
-=
1
;
}
return
{
time
:
line
.
time
,
time
:
line
.
time
>
0
?
line
.
time
:
0
,
index
:
lineObj
.
index
};
},
...
...
@@ -646,11 +666,11 @@ cc.Class({
// })
// console.log(n._id,ss,breakIndex,tm, idx, n.x,n.y);
n
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
)
n
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
n
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
function
()
{
console
.
log
(
n
.
_id
,
ss
,
breakIndex
,
tm
,
idx
,
n
.
x
,
n
.
y
,
this
.
richText
.
node
.
children
.
indexOf
(
n
)
);
this
.
calcSentenceRichText
.
string
=
this
.
sentenceContent
[
tm
];
this
.
playByTime
(
tm
);
});
}
,
this
);
const
s
=
n
.
getComponent
(
cc
.
Label
).
string
;
this
.
findSentenceIndexByWords
(
s
,
sentenceIndexObj
);
}
...
...
@@ -845,6 +865,9 @@ cc.Class({
if
(
overrideTime
)
{
startTime
=
overrideTime
;
}
if
(
startTime
<
0
)
{
startTime
=
0
;
}
this
.
playByTimePhaseStartTime
=
startTime
;
this
.
playByTimePhaseEndTime
=
endTime
;
this
.
playByTimePhaseStep
=
step
;
...
...
@@ -967,6 +990,9 @@ cc.Class({
this
.
resetLRC
();
},
seek
(
time
)
{
if
(
time
<
0
)
{
time
=
0
}
const
adSrc
=
this
.
getCurrentPlayingSource
();
adSrc
.
setCurrentTime
(
time
);
},
...
...
@@ -994,18 +1020,39 @@ cc.Class({
},
onDestroy
()
{
console
.
log
(
'
onDestroy onDestroy
'
);
// audioEngine.uncache(this.audioUrl);
if
(
this
.
_currentAudioId
)
{
audioEngine
.
stop
(
this
.
_currentAudioId
);
}
if
(
this
.
_audioSource
)
{
console
.
log
(
'
this._audioSource:
'
,
this
.
_audioSource
);
if
(
this
.
_audioSource
&&
this
.
_audioSource
.
audio
)
{
this
.
_audioSource
.
audio
.
stop
()
this
.
_audioSource
.
stop
();
// this._audioSource.audio.destroy();
this
.
_audioSource
.
audio
=
null
;
// this._audioSource._destruct();
}
if
(
this
.
_audioACSource
)
{
console
.
log
(
'
this._audioACSource:
'
,
this
.
_audioACSource
);
if
(
this
.
_audioACSource
&&
this
.
_audioACSource
.
audio
)
{
this
.
_audioACSource
.
audio
.
stop
()
this
.
_audioACSource
.
stop
();
// this._audioACSource.audio.destroy();
this
.
_audioACSource
.
audio
=
null
;
// this._audioSource._destruct();
}
// if (this._audioSource && this._audioSource.isValid) {
// this._audioSource.destroy();
// // this._audioSource._destruct();
// }
// if (this._audioACSource && this._audioACSource.isValid) {
// this._audioACSource.destroy();
// // this._audioACSource._destruct();
// }
// this._audioSource = null;
// this._audioACSource = null;
// this._destruct();
}
});
assets/sb_karaoke_cocos/scene/sb_karaoke_cocos.fire
View file @
c255575c
...
...
@@ -256,7 +256,7 @@
"__id__": 3
},
"_enabled": true,
"alignMode":
1
,
"alignMode":
2
,
"_target": null,
"_alignFlags": 45,
"_left": 0,
...
...
@@ -504,7 +504,7 @@
"__id__": 9
},
"_enabled": true,
"alignMode":
1
,
"alignMode":
2
,
"_target": null,
"_alignFlags": 44,
"_left": 0,
...
...
@@ -2263,7 +2263,7 @@
"__id__": 52
},
"_enabled": true,
"alignMode":
1
,
"alignMode":
2
,
"_target": null,
"_alignFlags": 45,
"_left": 0,
...
...
@@ -5378,7 +5378,7 @@
"__id__": 2
},
"_enabled": true,
"alignMode":
1
,
"alignMode":
2
,
"_target": null,
"_alignFlags": 45,
"_left": 0,
...
...
assets/sb_karaoke_cocos/scene/sb_karaoke_cocos.js
View file @
c255575c
...
...
@@ -85,6 +85,18 @@ cc.Class({
},
getData
(
func
)
{
if
(
window
&&
window
.
courseware
)
{
window
.
courseware
.
getData
(
func
,
'
scene
'
);
return
;
}
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
getData
(
func
);
return
;
}
func
(
this
.
getDefaultData
());
},
...
...
@@ -470,7 +482,7 @@ cc.Class({
}
rectNode
.
addComponent
(
cc
.
Button
);
rectNode
.
on
(
'
click
'
,
()
=>
{
rectNode
.
on
(
'
click
'
,
function
()
{
if
(
rectNode
.
isClicked
)
{
// return;
}
...
...
@@ -486,7 +498,7 @@ cc.Class({
if
(
animationNames
.
length
>
0
)
{
dragonDisplay
.
playAnimation
(
animationNames
[
0
],
1
);
}
});
}
,
this
);
}
});
...
...
@@ -534,12 +546,12 @@ cc.Class({
});
picNode
.
addComponent
(
cc
.
Button
);
picNode
.
on
(
'
click
'
,
()
=>
{
picNode
.
on
(
'
click
'
,
function
()
{
if
(
picNode
.
audioClip
)
{
cc
.
audioEngine
.
stopAllEffects
();
cc
.
audioEngine
.
playEffect
(
picNode
.
audioClip
,
false
,
0.8
);
}
});
}
,
this
);
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment