Commit f3991b35 authored by 李维's avatar 李维

使用转码视频

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