3
* Helioviewer.org - Latest Movie player
7
* This page was put together as a quick hack to provide a simple way to show
8
* what users have been uploading on Helioviewer.org at conferences, etc.
10
* It has not been advertised outside of the meeting, or made available on
13
* One possibility would be to provide a button on the main site which opens
14
* a jQuery dialog with the video player portion of the contents below.
20
<title>Helioviewer.org - Latest Movies</title>
21
<meta charset="utf-8" />
22
<script src="../lib/swfobject/swfobject.js"></script>
23
<style type='text/css'>
25
background-image: url('../resources/images/backgrounds/gradient_v5-optimized.png');
26
background-color: #20242F;
27
background-repeat: repeat-x;
30
#header {height: 50px;}
36
<h1 id="title">Helioviewer.org - Latest Movies</h1>
38
<div id="player"></div>
41
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
53
action: 'getUserVideos',
56
$.post("../api/index.php", params, parseUserVideos, "json");
59
function parseUserVideos(response) {
60
var params, attrs, startURL, width, height;
62
playlist.videos = parseYoutubeVideoIds(response);
66
allowScriptAccess: "always",
67
allowfullscreen: "true"
69
attrs = {id: "moviePlayer"};
71
playlist.current_video = 0;
73
startURL = "http://www.youtube.com/v/" + playlist.videos[0] + "?" + $.param({
75
playerapiid: "ytplayer",
79
width = $(window).width() * 0.8;
80
height = $(window).height() * 0.8;
82
swfobject.embedSWF(startURL, "player", width, height, "8", "../lib/swfobject/expressinstall.swf", null, params, attrs);
87
// YouTube JavaScript Player Callbacks
88
// https://developers.google.com/youtube/js_api_reference
89
function onYouTubePlayerReady(playerId) {
90
playlist.player = document.getElementById("moviePlayer");
91
playlist.player.addEventListener("onStateChange", "onStateChange");
92
playlist.player.playVideo();
95
function onStateChange(newstate) {
100
// Re-query latest videos once we get to the end of the loop
101
if ((playlist.current_video + 1) === playlist.videos.length) {
104
action: 'getUserVideos',
108
$.post("../api/index.php", params, function(response) {
109
playlist.videos = parseYoutubeVideoIds(response);
114
// Otherwise play the next video in the queue
115
loadVideo((playlist.current_video + 1) % playlist.videos.length);
119
function loadVideo(i) {
121
playlist.current_video = i;
122
playlist.player.loadVideoById(playlist.videos[playlist.current_video], null, "highres");
125
function parseYoutubeVideoIds(response) {
128
$.each(response, function (i, video) {
129
var id = video.url.split("=").pop();
b'\\ No newline at end of file'