Trying to get onYouTubePlayerReady to fire - youtube-api

I'm taking my first step with learning the YouTube api.
Here's my html:
<iframe width="640" height="360" src="//www.youtube.com/v/FLMpFXUZOs4?version=3&enablejsapi=1&rel=0" frameborder="0" allowfullscreen></iframe>
And here's my JavaScript:
function onYouTubePlayerReady() {
alert('yay!')
}
onYouTubePlayerReady is not firing.
I tried to save it in jsFiddle, but I don't see a Save button.
I only see a "Run", "Debug on mobile", "Tidyup", "JSHint" and "Collaboration" button.

Related

Youtube embedded video problem (video unavailable)

I've a got a problem when I'd like to embed a YouTube video on my expo application, when I click on the play button, I sometimes get this message :
For example, when I posted this video on reddit, it played perfectly through their youtube embedded player.
I use this sample of code:
<WebView
useWebKit={true}
ref={(ref) => { this.videoPlayer = ref;}}
source={{uri: 'https://www.youtube.com/embed/bo_efYhYU2A?rel=0&autoplay=0&showinfo=0&controls=0'}}
scrollEnabled={false}
domStorageEnabled={true}
javaScriptEnabled={true}
/>
I know for a fact that the video is allowed to be embedded because when it's not the case, I get a different error message which allows me to open the video on youtube :
Here is a link to test it : https://snack.expo.io/#maxgfr/youtube-embedded
Any help would be greatly appreciated
Maxime
Edit : example of url which doesn't work https://www.youtube.com/embed/8GaWM2a3FAc
To solve this problem :
I create a web application which loads a youtube video thanks to the video ID. My endpoint is something like that : https://mywebsite.com/ID_VIDEO_YOUTUBE
Then in my react native application, I just have to load the URL of my website :
<WebView
useWebKit={true}
ref={(ref) => { this.videoPlayer = ref;}}
source={{uri: 'https://mywebsite.com/ID_VIDEO_YOUTUBE'}}
scrollEnabled={false}
domStorageEnabled={true}
javaScriptEnabled={true}
/>
Edit : Here is the sample of code that I use in my Vue JS application
<template>
<div style="position: fixed;overflow-y: hidden;overflow-x: hidden;width:100%;height:100%;">
<iframe style="width:100%;height:100%;" :src="'https://www.youtube.com/embed/'+this.$route.params.id+'?&autoplay=1&playsinline=1'" autoplay="1" playsinline="1" frameborder="0" scrolling="no" allow="playsinline; accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</template>
<script>
export default {
name: 'youtube',
head: {
link: [{
r: 'icon',
h: '/static/favicon.png',
t: 'image/png'
}]
}
}
</script>

allowfullscreen is not working on frameset

I have an old service working on frameset-frame (I know it's deprecated but I have no choice) and users can add youtube iframe tags.
but from some point the fullscreen action is not working anymore(it used to work).
There's allowfullscreen attribute added already.
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ea9pOiwzd0c" frameborder="0" allowfullscreen></iframe>
I tried allowfullscreen on frameset and frame tag also.
I have tried like
allowfullscreen
allowfullscreen="true"
allowfullscreen="allowfullscreen"
mozallowfullscreen="mozallowfullscreen"
msallowfullscreen="msallowfullscreen"
oallowfullscreen="oallowfullscreen"
webkitallowfullscreen="webkitallowfullscreen"
... everything I can find on web but nothing worked for me.
You can try
allowfullscreen=true

embed a YouTube video in an XPages repeat control

I'm looking to embed a YouTube video into an XPage, probably into a repeat control. I've looked around but can't find anything specific to XPages. I can create a link to open the YouTube video but that just moves them to YouTube but I don't want to leave my site.
Does someone have an example of how to do this.
Use the HTML <iframe>, <object> or <embed> tag to insert YouTube videos into your XPage repeat control.
Example:
<xp:repeat
id="repeat1"
rows="30"
var="video"
indexVar="number">
<xp:this.value><![CDATA[#{javascript:
[ "http://www.youtube.com/embed/XMoTb1iep48",
"http://www.youtube.com/embed/lvs3vpmEKHg",
"http://www.youtube.com/embed/63lYaeOJZOA",
"http://www.youtube.com/embed/6D6PzLSlEsQ"
]
}]]></xp:this.value>
<iframe
width="400"
height="250"
style="margin:2em"
src="#{video}"
frameborder="0"
allowfullscreen="allowfullscreen">
</iframe>
<xp:text
rendered="#{javascript:(number + 1) % 2 == 0}">
<br />
</xp:text>
</xp:repeat>
Make sure you use http://www.youtube.com/embed/YOUR_VIDEO_ID as URL.
A detailed description you can find here.
You need to follow instructions and put a short snippet anywhere in the XPage. Something like:
<iframe title="YouTube video player" class="youtube-player" type="text/html"
width="640" height="390" src="http://www.youtube.com/embed/-X2zNe3YFNM"
frameborder="0" allowFullScreen></iframe>
With too many rows in your repeat you can expect lots of iframe reloads on every refresh.

Remove youtube Controls & Info in PrettyPhoto

This one is tricky, it works if you embed the code with an iframe:
<iframe width="560" height="315" src="http://www.youtube.com/watch?v=gzKAut3sVrw?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
However using PrettyPhoto i need to use it like this:
http://www.youtube.com/watch?v=gzKAut3sVrw?rel=0&controls=0&showinfo=0
the only thing working here is the rel=0
any ideas on how to make it work?
I was also struggling to hide YouTube controls when using PrettyPhoto. PrettyPhoto lets you specify iframe markup. This is where you have to add your extra YouTube parameters (after {path}).
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto({
keyboard_shortcuts: false,
iframe_markup: '<iframe src ="{path}&controls=0&showinfo=0" width="{width}" height="{height}" frameborder="no"></iframe>'
});
});
</script>

Help with youtube embed!

Help! Could someone please tell me what I'm doing wrong? I'm trying to produce a clickable image link so that when clicked it will start my youtube video. Here's what I have...
<iframe class="youtube" width="400" height="257" src="http://www.youtube.com/embed/I-TiwjSELQE?autoplay=1" frameborder="0" allowfullscreen imgsrc="images/ciafree-yt" width="413" height="242"></iframe>
Thank you : )
You could use jQuery and simply add id="yt-video" to your embed code.
Make sure you reference jQuery (https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js) in your HTML as well.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" ></script>
Then add this simple jQuery:
<script>
$(document).ready(function() {
$('#yt-video').hide(); // hides the video initially
$('#id_of_image_div_clicked').click(function(){
$('#id_of_image_div_clicked').hide(); // hides the clicked image
$('#yt-video').show(); // shows the video
}
});
</script>
If don't matters for you try to use <object> tags like I'm using

Resources