Commit 54d9ca8f authored by liujiangnan's avatar liujiangnan

feat: 添加_l处理

parent 95abd31c
This diff is collapsed.
{ {
"name": "ng-template-generator", "name": "ng-template-generator",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"start": "ng serve", "start": "ng serve",
"build": "ng build --build--optimizer --aot --base-href /JGT/v3/", "build": "ng build --build--optimizer --aot --base-href /JGT/v3/",
"publish": "node ./bin/publish.js" "publish": "node ./bin/publish.js"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
"nedb": "^1.8.0", "nedb": "^1.8.0",
"ng-lottie": "^0.3.1", "ng-lottie": "^0.3.1",
"ng-zorro-antd": "^7.2.0", "ng-zorro-antd": "^7.2.0",
"node-sass": "^4.14.1",
"npm": "^6.5.0", "npm": "^6.5.0",
"rxjs": "^6.3.3", "rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3", "rxjs-compat": "^6.3.3",
......
...@@ -30,9 +30,64 @@ export class PlayComponent implements AfterViewInit, OnInit, OnDestroy { ...@@ -30,9 +30,64 @@ export class PlayComponent implements AfterViewInit, OnInit, OnDestroy {
constructor(private appRef: ApplicationRef) { constructor(private appRef: ApplicationRef) {
} }
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.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) {
console.log("Send Get Request error: ", e)
}
}
getVideoUrl() {
const url1 = this.data.contentObj.video_url;
const url2 = url1.replace(/.mp4$/g, "_l.mp4");
this.httpHeadCall(url2, (success) => {
if (success) {
this.data.contentObj.video_url = url2;
}
})
}
ngOnInit() { ngOnInit() {
// console.log(this.data.contentObj)
// this.hasVideo = !!this.data.contentObj.video_url && typeof this.data.contentObj.video_url === 'string';
this.data = {}; this.data = {};
this.data.contentObj = {}; this.data.contentObj = {};
...@@ -54,6 +109,9 @@ export class PlayComponent implements AfterViewInit, OnInit, OnDestroy { ...@@ -54,6 +109,9 @@ export class PlayComponent implements AfterViewInit, OnInit, OnDestroy {
this.initDefaultData(); this.initDefaultData();
console.log('this.data.contentObj.video_url: ', this.data.contentObj.video_url); console.log('this.data.contentObj.video_url: ', this.data.contentObj.video_url);
if (this.data.contentObj.video_url) {
this.getVideoUrl();
}
this.hasVideo = !!this.data.contentObj.video_url && typeof this.data.contentObj.video_url === 'string'; this.hasVideo = !!this.data.contentObj.video_url && typeof this.data.contentObj.video_url === 'string';
......
This diff is collapsed.
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