/templates/test.html

http://radioappz.googlecode.com/ · HTML · 225 lines · 193 code · 30 blank · 2 comment · 0 complexity · e58d0db0c22fe21d17f3bc5b28589091 MD5 · raw file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>
  7. YouTube Chromeless Player Example page
  8. </title>
  9. <script src="http://www.google.com/jsapi"></script>
  10. <script>
  11. google.load("swfobject", "2.1");
  12. </script>
  13. <script type="text/javascript">
  14. function updateHTML(elmId, value) {
  15. document.getElementById(elmId).innerHTML = value;
  16. }
  17. function setytplayerState(newState) {
  18. updateHTML("playerstate", newState);
  19. }
  20. function onYouTubePlayerReady(playerId) {
  21. ytplayer = document.getElementById("myytplayer");
  22. setInterval(updateytplayerInfo, 250);
  23. updateytplayerInfo();
  24. ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
  25. ytplayer.addEventListener("onError", "onPlayerError");
  26. }
  27. function onytplayerStateChange(newState) {
  28. setytplayerState(newState);
  29. }
  30. function onPlayerError(errorCode) {
  31. alert("An error occured: " + errorCode);
  32. }
  33. function updateytplayerInfo() {
  34. updateHTML("bytesloaded", getBytesLoaded());
  35. updateHTML("bytestotal", getBytesTotal());
  36. updateHTML("videoduration", getDuration());
  37. updateHTML("videotime", getCurrentTime());
  38. updateHTML("startbytes", getStartBytes());
  39. updateHTML("volume", getVolume());
  40. }
  41. // functions for the api calls
  42. function loadNewVideo(id, startSeconds) {
  43. if (ytplayer) {
  44. ytplayer.loadVideoById(id, parseInt(startSeconds));
  45. }
  46. }
  47. function cueNewVideo(id, startSeconds) {
  48. if (ytplayer) {
  49. ytplayer.cueVideoById(id, startSeconds);
  50. }
  51. }
  52. function play() {
  53. if (ytplayer) {
  54. ytplayer.playVideo();
  55. }
  56. }
  57. function pause() {
  58. if (ytplayer) {
  59. ytplayer.pauseVideo();
  60. }
  61. }
  62. function stop() {
  63. if (ytplayer) {
  64. ytplayer.stopVideo();
  65. }
  66. }
  67. function getPlayerState() {
  68. if (ytplayer) {
  69. return ytplayer.getPlayerState();
  70. }
  71. }
  72. function seekTo(seconds) {
  73. if (ytplayer) {
  74. ytplayer.seekTo(seconds, true);
  75. }
  76. }
  77. function getBytesLoaded() {
  78. if (ytplayer) {
  79. return ytplayer.getVideoBytesLoaded();
  80. }
  81. }
  82. function getBytesTotal() {
  83. if (ytplayer) {
  84. return ytplayer.getVideoBytesTotal();
  85. }
  86. }
  87. function getCurrentTime() {
  88. if (ytplayer) {
  89. return ytplayer.getCurrentTime();
  90. }
  91. }
  92. function getDuration() {
  93. if (ytplayer) {
  94. return ytplayer.getDuration();
  95. }
  96. }
  97. function getStartBytes() {
  98. if (ytplayer) {
  99. return ytplayer.getVideoStartBytes();
  100. }
  101. }
  102. function mute() {
  103. if (ytplayer) {
  104. ytplayer.mute();
  105. }
  106. }
  107. function unMute() {
  108. if (ytplayer) {
  109. ytplayer.unMute();
  110. }
  111. }
  112. function getEmbedCode() {
  113. alert(ytplayer.getVideoEmbedCode());
  114. }
  115. function getVideoUrl() {
  116. alert(ytplayer.getVideoUrl());
  117. }
  118. function setVolume(newVolume) {
  119. if (ytplayer) {
  120. ytplayer.setVolume(newVolume);
  121. }
  122. }
  123. function getVolume() {
  124. if (ytplayer) {
  125. return ytplayer.getVolume();
  126. }
  127. }
  128. function clearVideo() {
  129. if (ytplayer) {
  130. ytplayer.clearVideo();
  131. }
  132. }
  133. </script>
  134. </head>
  135. <body id="page">
  136. <div>
  137. <p>Click "Load Video" or "Cue Video" below to start playing a video. <br />To play a different
  138. video, enter a YouTube video id and click "Load Video" or "Cue Video" again.</p>
  139. <!-- embed the player -->
  140. <div id="ytapiplayer">
  141. You need Flash player 8+ and JavaScript enabled to view this video.
  142. </div>
  143. <script type="text/javascript">
  144. // <![CDATA[
  145. // allowScriptAccess must be set to allow the Javascript from one
  146. // domain to access the swf on the youtube domain
  147. var params = { allowScriptAccess: "always", bgcolor: "#cccccc" };
  148. // this sets the id of the object or embed tag to 'myytplayer'.
  149. // You then use this id to access the swf and make calls to the player's API
  150. var atts = { id: "myytplayer" };
  151. swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer",
  152. "ytapiplayer", "400", "300", "8", null, null, params, atts);
  153. //]]>
  154. </script>
  155. <!-- HTML below here is for display of the player info + state -->
  156. <div>
  157. Player state: <span id="playerstate">--</span>
  158. </div>
  159. <br />
  160. <a href="javascript:void(0);" onclick="play();">Play</a> | <a href="javascript:void(0);" onclick="pause();">Pause</a> | <a href="javascript:void(0);" onclick="stop();">Stop</a> | <a href="javascript:void(0);" onclick="mute();">Mute</a> | <a href="javascript:void(0);" onclick="unMute();">Unmute</a>
  161. <br /><br />
  162. <form action="" onsubmit="seekTo(document.getElementById('seekto').value); return false;">
  163. <div><input id="seekto" type="text" size="4" /><input type="submit" value="Seek to" /></div>
  164. </form>
  165. <br />
  166. <div>
  167. Duration: <span id="videoduration">--:--</span> | Current Time: <span id="videotime">--:--</span>
  168. </div>
  169. <br />
  170. <div id="bytesdisplay">
  171. Bytes Total: <span id="bytestotal">--</span> | Start Bytes: <span id="startbytes">--</span> | Bytes Loaded: <span id="bytesloaded">--</span>
  172. </div>
  173. <br />
  174. <div>
  175. <input type="text" size="11" id="loadvideoid" value="u1zgFlCw8Aw" />
  176. <a href="javascript:void(0)" onclick="loadNewVideo(document.getElementById('loadvideoid').value, document.getElementById('startseconds').value)">&lt;-
  177. Load video</a> | Start at: <input type="text" size="4" id="startseconds" value="0" />
  178. </div>
  179. <br />
  180. <div>
  181. <input id="vol" type="text" size="2" />
  182. <a href="javascript:void(0)" onclick="setVolume(document.getElementById('vol').value)">&lt;- Set Volume</a> | Volume: <span id="volume">--</span>
  183. </div>
  184. <br />
  185. <div>
  186. <input type="text" size="11" id="cuevideoid" value="u1zgFlCw8Aw" />
  187. <a href="javascript:void(0)" onclick="cueNewVideo(document.getElementById('cuevideoid').value, document.getElementById('startseconds2').value)">&lt;- Cue video</a> | Start at: <input type="text" size="4" id="startseconds2" value="0" />
  188. </div>
  189. <br />
  190. <div>
  191. <a href="javascript:void(0)" onclick="getEmbedCode()">Get Embed Code</a> | <a href="javascript:void(0)" onclick="getVideoUrl()">Get Video URL</a> | <a href="javascript:void(0);" onclick="clearVideo()">Clear Video</a>
  192. </div>
  193. </div>
  194. </body>
  195. </html>