Comments (12)
Same here. Installed via Bower, included the jquery.youtubebackground.js
, called the player like this:
$('.heading-youtube').YTPlayer({
fitToBackground: true,
videoId: $('.heading-youtube').data('youtube-video'),
playerVars: {
modestbranding: 0,
autoplay: 1,
controls: 0,
showinfo: 0,
branding: 0,
rel: 0,
autohide: 0,
start: 0
}
});
And getting undefined
:(
from jquery.youtubebackground.
try
console.log( jQuery('#youtube_5BgZcS_3Lms').data('ytPlayer').player );
from jquery.youtubebackground.
I get null when I do that on my site. I just want to pause the video :(
from jquery.youtubebackground.
@jacobraccuia any code to share?
from jquery.youtubebackground.
if(typeof YTPlayer == 'object') {
player = $('.video-container .tv').YTPlayer({
fitToBackground: true,
pauseOnScroll: false,
videoId: $('.video-container .tv').data('video-id'),
});
console.log( jQuery('.video-container .tv').data('ytPlayer').player );
}
from jquery.youtubebackground.
Try using id's. What does your html look like?
from jquery.youtubebackground.
Still null. Here is my HTML and new JS
<div class="tv" id="fw_video_bg" data-video-id="' . $video_ID . '"></div>';
player = $('#fw_video_bg').YTPlayer({
fitToBackground: true,
pauseOnScroll: false,
videoId: $('#fw_video_bg').data('video-id'),
});
console.log( jQuery('#fw_video_bg').data('ytPlayer').player );
from jquery.youtubebackground.
Do you have more than one video? Is there a race condition going on? Is the video working at all?
from jquery.youtubebackground.
from jquery.youtubebackground.
This is weird.
jQuery('#fw_video_bg').data('ytPlayer');
returns the object with the player key there and all of the data as well, but
jQuery('#fw_video_bg').data('ytPlayer').player
returns null.
from jquery.youtubebackground.
@jacobraccuia I have the exact same problem and after referencing the following SO link:
https://stackoverflow.com/questions/17546953/cant-access-object-property-even-though-it-exists-returns-undefined
I wrap that with a setTimeout and it works now. It could be when you access the player it is not ready yet.
from jquery.youtubebackground.
Put the jQuery('#fw_video_bg').data('ytPlayer'); in callback function
it works for me
read here
#60 (comment)
from jquery.youtubebackground.
Related Issues (20)
- how can i catch an event on playback start ? HOT 1
- Related Videos
- Image in div set to display:none HOT 1
- Flickering at the end HOT 1
- Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://www.youtube.com’) does not match the recipient window’s origin HOT 7
- Two containers are created
- resize bug regular videos HOT 2
- Play/pause buttons don't work HOT 1
- Doesn't work in a hidden div (e.g. in a carousel/slider)
- Lazyload option exist here? HOT 1
- IE 11 related video still showing doesn't respond to "rel=0" HOT 1
- Don't play background video on Ipad HOT 1
- set audio volume? HOT 1
- How to disable related videos HOT 1
- resizing manually
- please update the doc Bower does not exist anymore
- video won't play on mobile views HOT 1
- ¿Use no-cookie youtube?
- Examples Wrong
- not as page background but as div background
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.youtubebackground.