iframe-flash.js
Go to the documentation of this file.
1 var mashTapeVideo = {
2  // Only resume playback if mT triggered the pause in the first place
3  paused: false,
4  pauseSongbird: function() {
5  if (songbird.playing && !songbird.paused)
6  {
7  mashTapeVideo.paused = true;
8  songbird.pause();
9  }
10  },
11 
12  resumeSongbird: function() {
13  if (songbird.paused && mashTapeVideo.paused)
14  {
15  mashTapeVideo.paused = false;
16  songbird.play();
17  }
18  },
19 
20  pauseVideo: function() {
21  var obj = document.getElementById("mTFlashObject");
22  if (!obj)
23  return;
24  switch(obj.getAttribute("mashTape-provider")) {
25  case "YouTube":
26  obj.pauseVideo();
27  break;
28  case "Yahoo Music":
29  obj.vidPause();
30  break;
31  case "MTV Music Video":
32  obj.pause();
33  break;
34  default:
35  return;
36  }
37  },
38 
39  // Provider specific listeners
40  youTubeListener: function(state) {
41  switch (state) {
42  case 1: // playing
43  case 3: // buffering
44  mashTapeVideo.pauseSongbird();
45  break;
46  case 0: // done playing
47  case 2: // paused
48  mashTapeVideo.resumeSongbird();
49  break;
50  default:
51  break;
52  }
53  },
54  yahooListener: function(eventType, eventInfo) {
55  if (eventType != "done")
56  return;
57  mashTapeVideo.resumeSongbird();
58  },
59 
60  mtvListener: function(state) {
61  // if no state parameter passed, then this is the MEDIA_ENDED
62  // event, and we're done with the video, so resume.
63  if (state == null || state == "stopped") {
64  mashTapeVideo.resumeSongbird();
65  }
66  },
67 
68  resizeHandler: function(e) {
69  e.preventDefault();
70  e.stopPropagation();
71 
72  var frameWidth = document.getElementsByTagName("html")[0].clientWidth;
73  var frameHeight = document.getElementsByTagName("html")[0].clientHeight;
74  //dump("New frame size: " + frameWidth + "x" + frameHeight + "\n");
75 
76  var swf = document.getElementById("mTFlashObject");
77  if (!swf)
78  return;
79 
80  var newHeight = frameHeight - 25; // 25px is more|less our padding
81  var ratio = document.getUserData("mashTapeRatio");
82  if (!ratio)
83  return;
84  var newWidth = newHeight * ratio;
85  if (newWidth > frameWidth - 25) {
86  newWidth = frameWidth - 25;
87  newHeight = newWidth / ratio;
88  }
89 
90  if (frameWidth - newWidth > 120) {
91  document.getElementById("content").style.clear = "none";
92  document.getElementById("author").style.display = "block";
93  } else {
94  document.getElementById("content").style.clear = "both";
95  document.getElementById("author").style.display = "inline";
96  var capHeight = document.getElementById("content").clientHeight;
97  if (frameHeight - newHeight < capHeight) {
98  newHeight = newHeight - capHeight;
99  newWidth = newHeight * ratio;
100  //dump("Adjustment: " + newWidth + "x" + newHeight + "\n");
101  }
102  }
103 
104  if (newWidth != swf.width && newWidth > 150 && newHeight > 50) {
105  //dump("Setting SWF size: "+newWidth + "x" + newHeight + "\n");
106  swf.width = newWidth;
107  swf.height = newHeight;
108  }
109  }
110 }
111 
112 window.addEventListener("songbirdPlaybackResumed", mashTapeVideo.pauseVideo, false);
113 window.addEventListener("unload", mashTapeVideo.resumeSongbird, false);
114 window.addEventListener("resize", mashTapeVideo.resizeHandler, false);
115 
116 // YouTube is hard-coded to look for a window-level function named
117 // 'onYouTubePlayerReady' which is invoked with the id of the object
118 function onYouTubePlayerReady(id) {
119  var p = document.getElementById("mTFlashObject");
120  p.addEventListener("onStateChange", "mashTapeVideo.youTubeListener");
121 }
let window
var mashTapeVideo
Definition: iframe-flash.js:1
function onYouTubePlayerReady(id)
return null
Definition: FeedWriter.js:1143