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="82iWIKejaiQ" width="260px" height="260px"></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
}
1 post - 1 participant