Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
ns_video_map
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
ns_video_map
Commits
aa313722
Commit
aa313722
authored
May 09, 2022
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 尝试使用优化版本的视频地址
parent
d008ca63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
15 deletions
+85
-15
ns_video_map.ts
assets/ns_video_map/scene/ns_video_map.ts
+85
-15
No files found.
assets/ns_video_map/scene/ns_video_map.ts
View file @
aa313722
...
...
@@ -88,9 +88,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
pauseBtn
.
active
=
false
;
}
async
refreshBtnState
()
{
refreshBtnState
()
{
await
asyncDelay
(
0.01
);
//
await asyncDelay(0.01);
if
(
this
.
video
.
isPlaying
())
{
this
.
pauseBtn
.
active
=
true
;
...
...
@@ -117,16 +117,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
video
=
null
initVideo
()
{
console
.
log
(
'
in initVideo...
'
)
if
(
this
.
data
.
video_url
)
{
this
.
initVideoRemote
();
this
.
getVideoUrl
(
(
url
)
=>
{
this
.
initVideoRemote
(
url
);
})
}
this
.
video
.
node
.
on
(
'
completed
'
,
()
=>
{
console
.
log
(
'
in completed!!!!
'
)
this
.
videoPlayEnd
();
})
}
getVideoUrl
(
callback
)
{
const
url1
=
this
.
data
.
video_url
;
const
url2
=
url1
.
replace
(
/.mp4$/g
,
"
_l.mp4
"
);
this
.
httpHeadCall
(
url2
,
(
success
)
=>
{
if
(
success
)
{
console
.
log
(
'
return url2:
'
,
url2
);
callback
(
url2
);
}
else
{
console
.
log
(
'
return url1:
'
,
url1
);
callback
(
url1
);
}
})
}
isPlayEnd
=
null
...
...
@@ -144,7 +161,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initVideoRemote
()
{
initVideoRemote
(
url
)
{
console
.
log
(
'
in initVideoRemote
'
)
const
videoLocalNode
=
cc
.
find
(
"
Canvas/videoBase/videoLocal
"
);
...
...
@@ -158,7 +176,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
video
.
resourceType
=
cc
.
VideoPlayer
.
ResourceType
.
REMOTE
;
video
.
remoteURL
=
this
.
data
.
video_
url
;
video
.
remoteURL
=
url
;
// video.isFullscreen = true;
video
.
stayOnBottom
=
true
;
...
...
@@ -189,12 +207,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
sy
=
canvas
.
height
/
height
;
video
.
node
.
scale
=
Math
.
min
(
sx
,
sy
);
console
.
log
(
'
canvas:
'
,
canvas
);
console
.
log
(
'
canvas.width:
'
,
canvas
.
width
);
console
.
log
(
'
e.node.width:
'
,
e
.
node
.
width
);
console
.
log
(
'
sx:
'
,
sx
);
console
.
log
(
'
sy:
'
,
sy
);
console
.
log
(
'
scale:
'
,
video
.
node
.
scale
);
//
console.log('canvas: ', canvas);
//
console.log('canvas.width: ', canvas.width);
//
console.log('e.node.width: ', e.node.width);
//
console.log('sx: ', sx);
//
console.log('sy: ', sy);
//
console.log('scale: ', video.node.scale);
video
.
play
();
// window["air"].hideAirClassLoading();
...
...
@@ -222,9 +240,61 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this
.
video
.
node
.
on
(
'
completed
'
,
()
=>
{
console
.
log
(
'
in completed!!!!
'
)
this
.
videoPlayEnd
();
})
}
httpHeadCall
(
requsetUrl
:
string
,
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
){
cc
.
error
(
e
)
}
};
xhr
.
open
(
"
HEAD
"
,
requsetUrl
,
true
);
// xhr.setRequestHeader('content-type', 'application/json');
// xhr.setRequestHeader('token', this.token);
// xhr.send(JSON.stringify(requestData));
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
)
{
cc
.
error
(
"
Send Get Request error:
"
,
e
)
}
}
...
...
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