~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to movies/latest.php

  • Committer: V. Keith Hughitt
  • Date: 2009-04-01 21:08:05 UTC
  • Revision ID: hughitt1@kore-20090401210805-372f7dgih07vxk42
nightly build 04-01-2009

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Helioviewer.org - Latest Movie player
4
 
 * 
5
 
 * July 2012
6
 
 * 
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.
9
 
 * 
10
 
 * It has not been advertised outside of the meeting, or made available on
11
 
 * the main site.
12
 
 * 
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. 
15
 
 */
16
 
?>
17
 
<!DOCTYPE html>
18
 
<html lang="en">
19
 
<head>
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'>
24
 
        body {
25
 
                        background-image: url('../resources/images/backgrounds/gradient_v5-optimized.png');
26
 
                        background-color: #20242F;
27
 
                        background-repeat: repeat-x;
28
 
                text-align: center;
29
 
        }
30
 
        #header {height: 50px;}
31
 
        #moviePlayer {}
32
 
    </style>
33
 
</head>
34
 
<body>
35
 
        <div id="header">
36
 
                <h1 id="title">Helioviewer.org - Latest Movies</h1>
37
 
        </div>
38
 
    <div id="player"></div>
39
 
 
40
 
<!-- Main -->
41
 
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
42
 
<script>
43
 
        // Global playlist
44
 
        var playlist = {
45
 
        videos: [],
46
 
        current_video: 0,
47
 
        player: null
48
 
    };
49
 
 
50
 
        $(function () {
51
 
                // Query params
52
 
                var params = {
53
 
                        action: 'getUserVideos',
54
 
                        num: 30
55
 
                };
56
 
            $.post("../api/index.php", params, parseUserVideos, "json");
57
 
        });
58
 
        
59
 
        function parseUserVideos(response) {
60
 
        var params, attrs, startURL, width, height;
61
 
        
62
 
        playlist.videos = parseYoutubeVideoIds(response);
63
 
        
64
 
        // Load SWFObject
65
 
        params = {
66
 
                allowScriptAccess: "always",
67
 
                allowfullscreen: "true"
68
 
        };
69
 
        attrs = {id: "moviePlayer"};
70
 
        
71
 
        playlist.current_video = 0;
72
 
        
73
 
        startURL = "http://www.youtube.com/v/" + playlist.videos[0] + "?" + $.param({
74
 
                enablejsapi: 1,
75
 
                playerapiid: "ytplayer",
76
 
                rel: 0
77
 
        });
78
 
        
79
 
        width  = $(window).width() * 0.8;
80
 
        height = $(window).height() * 0.8;
81
 
        
82
 
        swfobject.embedSWF(startURL, "player", width, height, "8", "../lib/swfobject/expressinstall.swf", null, params, attrs);
83
 
    }
84
 
    
85
 
    //suggestedQuality
86
 
 
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();
93
 
    }
94
 
 
95
 
    function onStateChange(newstate) {
96
 
        if (newstate !== 0) {
97
 
                        return;         
98
 
        }
99
 
 
100
 
                // Re-query latest videos once we get to the end of the loop
101
 
        if ((playlist.current_video + 1) === playlist.videos.length) {
102
 
                        // Query params
103
 
                        var params = {
104
 
                                action: 'getUserVideos',
105
 
                                num: 30
106
 
                        };
107
 
 
108
 
                $.post("../api/index.php", params, function(response) {
109
 
                        playlist.videos = parseYoutubeVideoIds(response);
110
 
                        
111
 
                        loadVideo(0);
112
 
                }, "json");
113
 
        } else {
114
 
                // Otherwise play the next video in the queue
115
 
                loadVideo((playlist.current_video + 1) % playlist.videos.length);
116
 
        }
117
 
    }
118
 
    
119
 
    function loadVideo(i) {
120
 
        // Load next video
121
 
        playlist.current_video = i;
122
 
        playlist.player.loadVideoById(playlist.videos[playlist.current_video], null, "highres");
123
 
    }
124
 
    
125
 
    function parseYoutubeVideoIds(response) {
126
 
        var ids = [];
127
 
        
128
 
        $.each(response, function (i, video) {
129
 
                var id = video.url.split("=").pop();            
130
 
                ids.push(id);
131
 
        });
132
 
        
133
 
        return ids;
134
 
    };
135
 
 
136
 
</script>
137
 
</body>
138
 
</html>
 
 
b'\\ No newline at end of file'