Click to search on your search term.
Subscribe to Fig Leaf Tutorials

Need help with a project? Contact us at
From code reviews to project "jumpstarts" and full life-cycle development, we've got you covered!
Check out our case studies!
Follow us on Twitter!
Click here to join our Facebook group!

Ready to upgrade your skills? Try these instructor-led classes in Washington, DC:

Displaying YouTube Videos with the YouTube iFrame API

Page of 168

The YouTube iFrame Player APIs give you more granular control over YouTube video playback within your Sencha Touch application. Use this API to configure basic settings, drive the player interface, and build your own player controls.

The following example class packages the major features of the YouTube iFrame API as a Sencha Touch component, thereby making it easy to instantiate a viewer and programatically start, stop, pause and load other videos into a single player instance.

Ext.define('MyApp.view.YouTubePlayer', {
 extend: 'Ext.Component',
 alias: 'widget.YouTubePlayer',

 config: {
  url: '',
  videoId: 'qsvpvqvApKo',
  vWidth: 420,
  vHeight: 315,
  autoPlay: 1,
  autoHide: 1,
  loop: 0,
  modestBranding: 1,
  start: 0

 onPlayerApiChange: function() {

 onPlayerError: function() {

 onPlayerPlaybackQualityChange: function() {

 onPlayerReady: function() {

 onPlayerStateChange: function() {

 initialize: function() {

  var me = this;

  window.onYouTubeIframeAPIReady = function() {
   me.player = new YT.Player(, {
    height: me.getVHeight(),
    width:  me.getVWidth(),
    videoId: me.getVideoId(),
    playerVars: {
     autohide: me.getAutoHide(),
     autoplay: me.getAutoPlay(),
     loop: me.getLoop(),
     modestbranding: me.getModestBranding(),
     start: me.getStart()
    events: {
     onApiChange : Ext.Function.bind(me.onPlayerApiChange,me),
     onError: Ext.Function.bind(me.onPlayerError, me),
     onPlaybackQualityChange: Ext.Function.bind(me.onPlayerPlaybackQualityChange,me),
     onReady: Ext.Function.bind(me.onPlayerReady,me),
     onStateChange: Ext.Function.bind(me.onPlayerStateChange, me)

  // load api if necessary
  if (typeof YT == 'undefined'){ 
   var tag = document.createElement('script');
   tag.src = "//";
   var firstScriptTag = document.getElementsByTagName('script')[0];
   firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

 stop: function() {

 play: function() {

 pause: function() {

 loadVideoById: function(videoId, startSeconds, endSeconds, suggestedQuality) {
    videoId: videoId,
    startSeconds: startSeconds,
    endSeconds: endSeconds,
    suggestedQuality: suggestedQuality
Page of 168
comments powered by Disqus