Issue
I did try to use the angular youTube player library in ionic 5. It did work like expected on Android, but do not show on ios.
Does somebody had the same problem and know how to fix it?
This is my code
// component.html
<youtube-player [videoId]="attributes?.youTubeLink" width="100%" height="auto"></youtube-player>
// module.ts
import { YouTubePlayerModule } from '@angular/youtube-player'
imports [
CommonModule,
IonicModule,
YouTubePlayerModule,
]
// component.ts
export class YouTubeComponent implements OnInit {
ngOnInit(): void {
loadScript('https://www.youtube.com/iframe_api')
}
}
// utilities.ts
export const loadScript = (target: string): void => {
if (!isScriptLoaded(target)) {
const tag = document.createElement('script')
tag.src = target
document.body.appendChild(tag)
}
}
const isScriptLoaded = (target: string): boolean => {
return document.querySelector('script[src="' + target + '"]') ? true : false
}
Solution
I needed to add the following to the config.xml
file.
<allow-navigation href="https://*youtube.com/*" />
Answered By - Raphaël Balet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.