Skip to content

Instantly share code, notes, and snippets.

@clonn
Created January 3, 2015 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clonn/f3a2966f48f69db9f2dc to your computer and use it in GitHub Desktop.
Save clonn/f3a2966f48f69db9f2dc to your computer and use it in GitHub Desktop.
youtube-player.coffee, for controller, should be install and use, could not insert before.
(($) ->
options =
videoId: "youtube video id"
width: "640"
height: "480"
playerVars:
autoplay: 0
controls: 1
modestbranding: 0
rel: 0
showInfo: 0
events:
onStateChange: (state) ->
$.fancybox(href: "#fill") if state.data is YT.PlayerState.ENDED
return
if typeof (YT) is "undefined" or typeof (YT.Player) is "undefined"
window.onYouTubePlayerAPIReady = ->
#div id
window.player = new YT.Player("video", options)
return
# window .player.addEventListener("onStateChange", "hello");
$.getScript "//www.youtube.com/player_api"
else
window.player = new YT.Player("video", options)
) jQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment