I need to directly link a URL to a youtube video. The idea is if you put the link in a mobile, I must be opened in youtube APP. I didn’t start to try it in an Andriod phone until now. In iOS, I’m not able to open directly in the APP.
I tried it in PHP and in Javascript.
In PHP I used header to make the redirect. But it didn’t work. I also used youtube scheme.
header("Location: http://www.youtube.com/v/T0WepLbWyq0");
header("Location: https://www.youtube.com/watch?v=T0WepLbWyq0");
header("Location: youtube://www.youtube.com/v/ T0WepLbWyq0");
In javascript, I tried the same but with windows.location:
<script>
window.location = "http://www.youtube.com/v/E91WD7sr_hU";
</script>
I discovered that if I put a “usual” link () it opens the APP as I want. Then I thought that maybe generating a click in javascript I will solve my issue. But It doesn’t work neither.
<a id="link-youtube" target="_blank" href="https://www.youtube.com/watch?v=T0WepLbWyq0">
<script>
document.getElementById("link-youtube").click();
</script>
Can somebody help me, please?
Thanks!