Commit 8903d1c1 authored by Tt's avatar Tt

修改视频加载方式

parent c2b1b7a9
...@@ -390,11 +390,29 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -390,11 +390,29 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layout_video.active = false; this.layout_video.active = false;
this.showUI(); this.showUI();
} }
initVideoPlayer() { @property(cc.Node) touchlayer : cc.Node = null;
initVideoUrl() {
this.prepared = true;
this.touchlayer.on(cc.Node.EventType.TOUCH_START, this.tryPlayVideo, this)
this.videoPlayer.node.active = true; this.videoPlayer.node.active = true;
this.videoPlayer.remoteURL = this.data.video_url; this.videoPlayer.remoteURL = this.data.video_url;
this.videoPlayer.resourceType = cc.VideoPlayer.ResourceType.REMOTE; this.videoPlayer.resourceType = cc.VideoPlayer.ResourceType.REMOTE;
}
private prepared: boolean;
tryPlayVideo() {
cc.log("touch layer--")
if (this.prepared) {
this.prepared = false;
this.videoPlayer.volume = 0;
this.videoPlayer.play();
this.scheduleOnce(() => {
this.videoPlayer.volume = 1;
this.videoPlayer.pause();
}, 1)
}
}
initVideoPlayer() {
this.videoPlayer.node.x = -10000; this.videoPlayer.node.x = -10000;
this.videoPlayer.node.y = -10000; this.videoPlayer.node.y = -10000;
this.layout_video.active = false; this.layout_video.active = false;
...@@ -403,7 +421,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -403,7 +421,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this._isReadyToPlay = true; this._isReadyToPlay = true;
this._isPlayComplated = false; this._isPlayComplated = false;
this.videoPlayer.currentTime = 0; this.videoPlayer.currentTime = 0;
this.play();
}); });
this.videoPlayer.node.on('meta-loaded', () => { this.videoPlayer.node.on('meta-loaded', () => {
console.log('meta-loaded'); console.log('meta-loaded');
...@@ -565,9 +582,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -565,9 +582,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
play() { play() {
if (!this._isReadyToPlay) { if (!this._isReadyToPlay) return;
return;
}
this.videoPlayer.play(); this.videoPlayer.play();
} }
pause() { pause() {
......
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