-5
我是新來的Angular 2和Ionic 2,所以我沒有得到如何獲取和顯示我的Angular 2 android應用程序的視頻的想法。如何從Ionic 2框架的Angular 2的Youtube頻道獲取視頻?
.component.js文件
export class HomePage implements OnInit {
private videoListArr = [];
private title = [];
private objArr;
baseUrl: string = 'https://www.youtube.com/embed/';
private homes = [];
constructor(private sanitizer: DomSanitizer, public navCtrl: NavController, private _homeService: HomeService) { }
ngOnInit() {
this._homeService.getHome()
.subscribe(response =>this.homes.push(JSON.parse(JSON.stringify(response))),
error => alert(error),
() => {
this.objArr = this.homes;
this.objArr[0].items.forEach(element => {
var url = element.snippet.resourceId.videoId;
this.title.push(element.snippet.title);
this.videoListArr.push({
videoUrl: this.sanitizer.bypassSecurityTrustResourceUrl(this.baseUrl + url),
videoTitle: element.snippet.title,
videoDesc: element.snippet.description
});
});
}
)
}
}
請添加一些代碼或任何你已經嘗試到目前爲止。 –
與喬恩聰明的補充嘗試科爾多瓦YoutubeVideoPlayer:https://github.com/JonSmart/CordovaYoutubeVideoPlayer – JanP
我解決了這個問題謝謝! – Pawan