Giter Site home page Giter Site logo

Comments (12)

hellor0bot avatar hellor0bot commented on August 22, 2024

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.

bento-n-box avatar bento-n-box commented on August 22, 2024

try
console.log( jQuery('#youtube_5BgZcS_3Lms').data('ytPlayer').player );

from jquery.youtubebackground.

jacobraccuia avatar jacobraccuia commented on August 22, 2024

I get null when I do that on my site. I just want to pause the video :(

from jquery.youtubebackground.

bento-n-box avatar bento-n-box commented on August 22, 2024

@jacobraccuia any code to share?

from jquery.youtubebackground.

jacobraccuia avatar jacobraccuia commented on August 22, 2024
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.

bento-n-box avatar bento-n-box commented on August 22, 2024

Try using id's. What does your html look like?

from jquery.youtubebackground.

jacobraccuia avatar jacobraccuia commented on August 22, 2024

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.

bento-n-box avatar bento-n-box commented on August 22, 2024

Do you have more than one video? Is there a race condition going on? Is the video working at all?

from jquery.youtubebackground.

jacobraccuia avatar jacobraccuia commented on August 22, 2024

from jquery.youtubebackground.

jacobraccuia avatar jacobraccuia commented on August 22, 2024

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.

redcomethk avatar redcomethk commented on August 22, 2024

@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.

altafhpatel avatar altafhpatel commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.