Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cartoon_video
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
cartoon_video
Commits
9e115bd2
Commit
9e115bd2
authored
Sep 20, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 视频高清处理
parent
1dccea74
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
13 deletions
+61
-13
cartoon_video.js
assets/cartoon_video/Scene/cartoon_video.js
+61
-13
No files found.
assets/cartoon_video/Scene/cartoon_video.js
View file @
9e115bd2
...
@@ -83,6 +83,63 @@ cc.Class({
...
@@ -83,6 +83,63 @@ cc.Class({
cc
.
director
[
'
_scene
'
].
height
=
frameSize
.
height
;
cc
.
director
[
'
_scene
'
].
height
=
frameSize
.
height
;
},
},
getVideoUrl
(
callback
)
{
const
url1
=
this
.
data
.
video_url
;
const
url2
=
url1
.
replace
(
/.mp4$/g
,
"
_h.mp4
"
);
this
.
httpHeadCall
(
url2
,
(
success
)
=>
{
if
(
success
)
{
console
.
log
(
'
return url2:
'
,
url2
);
callback
(
url2
);
}
else
{
console
.
log
(
'
return url1:
'
,
url1
);
callback
(
url1
);
}
})
},
httpHeadCall
(
requsetUrl
,
callback
)
{
let
xhr
=
new
XMLHttpRequest
();
console
.
log
(
"
Status: Send Post Request to
"
+
requsetUrl
);
try
{
xhr
.
onreadystatechange
=
()
=>
{
try
{
console
.
log
(
'
xhr.readyState:
'
,
xhr
.
readyState
);
if
(
xhr
.
readyState
==
4
)
{
if
((
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
callback
(
true
);
}
else
{
callback
(
false
);
}
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
};
xhr
.
open
(
"
HEAD
"
,
requsetUrl
,
true
);
xhr
.
send
();
xhr
.
timeout
=
15000
;
xhr
.
onerror
=
(
e
)
=>
{
console
.
log
(
"
汪汪汪 posterror
"
,
e
);
callback
(
false
);
};
xhr
.
ontimeout
=
(
e
)
=>
{
console
.
log
(
"
汪汪汪 ontimeout
"
,
e
);
callback
(
false
);
};
}
catch
(
e
)
{
console
.
log
(
"
Send Get Request error:
"
,
e
)
}
},
// use this for initialization
// use this for initialization
onLoad
()
{
onLoad
()
{
...
@@ -250,8 +307,10 @@ cc.Class({
...
@@ -250,8 +307,10 @@ cc.Class({
getData
(
async
(
data
)
=>
{
getData
(
async
(
data
)
=>
{
console
.
log
(
'
data:
'
,
JSON
.
stringify
(
data
));
console
.
log
(
'
data:
'
,
JSON
.
stringify
(
data
));
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
getVideoUrl
(
videoUrl
=>
{
this
.
data
.
video_url
=
videoUrl
;
this
.
videoPlayer
.
remoteURL
=
this
.
data
.
video_url
;
this
.
videoPlayer
.
remoteURL
=
this
.
data
.
video_url
;
// this.preload()
});
await
this
.
initView
();
await
this
.
initView
();
if
(
window
&&
window
[
"
air
"
])
{
if
(
window
&&
window
[
"
air
"
])
{
window
[
"
air
"
].
hideAirClassLoading
();
window
[
"
air
"
].
hideAirClassLoading
();
...
@@ -356,17 +415,6 @@ cc.Class({
...
@@ -356,17 +415,6 @@ cc.Class({
this
.
triggerInteractive
();
this
.
triggerInteractive
();
},
},
preload
()
{
cc
.
assetManager
.
loadAny
({
url
:
this
.
data
.
video_url
},
{
cacheAsset
:
true
},
null
,
(
err
,
data
)
=>
{
console
.
log
(
'
preload data,
'
,
data
);
// typeof
if
(
window
&&
window
[
"
air
"
])
{
window
[
"
air
"
].
hideAirClassLoading
();
}
});
},
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
cc
.
audioEngine
.
stopAll
();
cc
.
audioEngine
.
stopAll
();
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
...
...
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