Commit f3991b35 authored by 李维's avatar 李维

使用转码视频

parent 8cbedf7d
...@@ -5,7 +5,8 @@ import { ...@@ -5,7 +5,8 @@ import {
asyncLoadRemote, asyncLoadRemote,
getSprNode, getSprNode,
playLocalAudio, playLocalAudio,
asyncGetVideoDuration asyncGetVideoDuration,
getVideoUrl
} from "../script/util_DG_FAF"; } from "../script/util_DG_FAF";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG_FAF"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG_FAF";
import { getUUID } from "../script/util_DG_FAF"; import { getUUID } from "../script/util_DG_FAF";
...@@ -2499,8 +2500,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2499,8 +2500,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showVideoLayer(); this.showVideoLayer();
const videoplayer = cc.find("Canvas/VideoPlayerContainer/videoPlayer").getComponent(cc.VideoPlayer) const videoplayer = cc.find("Canvas/VideoPlayerContainer/videoPlayer").getComponent(cc.VideoPlayer)
videoplayer.stayOnBottom = true; videoplayer.stayOnBottom = true;
if( videoplayer.remoteURL != contentData.video_url ) { const video_url = await getVideoUrl(contentData.video_url);
videoplayer.remoteURL = contentData.video_url; if( videoplayer.remoteURL != video_url ) {
videoplayer.remoteURL = video_url;
} }
this.videoDuration = await asyncGetVideoDuration(videoplayer); this.videoDuration = await asyncGetVideoDuration(videoplayer);
// 设置进度条的起始和结束标签 // 设置进度条的起始和结束标签
......
...@@ -454,7 +454,6 @@ export function httpHeadCall(requsetUrl: string, callback) { ...@@ -454,7 +454,6 @@ export function httpHeadCall(requsetUrl: string, callback) {
try { try {
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
try { try {
console.log('xhr.readyState: ', xhr.readyState);
if (xhr.readyState == 4) { if (xhr.readyState == 4) {
if ((xhr.status >= 200 && xhr.status < 400)) { if ((xhr.status >= 200 && xhr.status < 400)) {
callback(true); callback(true);
...@@ -534,22 +533,19 @@ export function asyncGetVideoDuration(video) { ...@@ -534,22 +533,19 @@ export function asyncGetVideoDuration(video) {
resovle(dur) resovle(dur)
}) })
} }
// 获取视频地址 // 获取视频地址
// export function getVideoUrl(callback) { export function getVideoUrl(video_url) {
// const url1 = this.data.video_url; return new Promise((resovle, reject) => {
// // 强制使用原视频 const video_url_h = video_url.replace(/.mp4$/g, "_m.mp4");
// // console.log("强制使用原视频") this.httpHeadCall(video_url_h, (success) => {
// // callback(url1); if (success) {
// // return // console.log('return video_url_h: ', video_url_h);
// // ==== End === resovle(video_url_h);
// const url2 = url1.replace(/.mp4$/g, "_h.mp4"); } else {
// this.httpHeadCall(url2, (success) => { // console.log('return video_url: ', video_url);
// if (success) { resovle(video_url);
// console.log('return url2: ', url2); }
// callback(url2); })
// } else { })
// console.log('return url1: ', url1); }
// callback(url1);
// }
// })
// }
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