1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html>
    <head>
        <title>CS50 Live</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js    "></script>
        <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet" />
        <script type="text/javascript" src="http://mirror.cs50.net/live50/js/swfobject.js"></script>
        <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
    </head>
    <body style="padding:0px;">
        <div id="player_wrapper" style="margin:auto; text-align:center; width:640px; padding:none">
<div id="StrobeMediaPlayback">
                <p>
                    Your browser does not support flash or live HTTP Streaming, please install flash or try another device.
                </p>
            </div>
        </div>
            <script type="text/javascript">

                WOWZA_ADDRESS = "d2styuku9jk2cq.cloudfront.net";
                APP_NAME = "liverecdvr";
                
                parse();

                function parse(stringtoparse)
                {
                    // parse get variables
                    var gs;

                    // check if the parse function was passed a get variable
                    if (typeof stringtoparse === "undefined")
                        gs = window.location.search.substr(1);
                    else
                        gs = stringtoparse.split("?")[1];
                    console.log("gs = " + gs)

                    var gsa = gs.split ("&");
                    g = {};

                    for (var i = 0; i < gsa.length; i++) {
                        var ta = gsa[i].split("=");
                        g[ta[0]] = ta[1];
                    }

                    var source = "http://" + WOWZA_ADDRESS + "/";
                    console.log(g);
                    // make sure we got a stream name passed
                    if(typeof g.streamname === "undefined" || g.streamname == "")
                    {
                        document.getElementById("StrobeMediaPlayback").innerHTML = "<p>NO STREAM NAME DEFINED</p>";
                        return false;
                    }
                    else
                    {
                        
                        console.log(g.streamname);

                        //add the app name
                        source += APP_NAME + "/";

                        // if we have DVR, we won't be doing multi-bitrate, user must select a raster
                        if (g.dvr == "true")
                        {
                            source += g.streamname;
                            var r = get_raster(g);
                            if (!r)
                            {
                                document.getElementById("StrobeMediaPlayback").innerHTML = "<p>INVALID OR NO SIZE DEFINED</p>";
                                return false;
                            }

                            // add the raster
                            // source += "_" + r + "/";
                            source += "/";
                        }
                       /* else
                        {
                            // no DVR check if we got a particular raster
                            var r = get_raster(g);
                            if (!r)
                            {
                                // not passed a raster, multi-bitrate
                                source += "ngrp:" + g.streamname + "_all/";
                            }
                            else
                            {
                                source += g.streamname + "_" + r + "/";
                            }
                        }
                        */

                        // check for iOS devices
                        if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 
                        {
                            // send the appropriate file if it's a dvr
                            if (g.dvr == "true")
                            {
                                //console.log (source + "playlist.m3u8?DVR");
                                window.location = source + "playlist.m3u8?DVR";
                            }
                            else
                            {   
                                // console.log(source + "playlist.m3u8");
                                window.location = source + "playlist.m3u8";
                            }
                        }
                        else
                        {
                            // not in iOS device
                            // send the appropriate file if it's a dvr
                            if (g.dvr == "true")
                            {
                                console.log (source + "manifest.f4m?DVR");
                                source = source + "manifest.f4m?DVR";
                            }
                            else
                            {   
                                console.log(source + "manifest.f4m");
                                source = source + "manifest.f4m";
                            }

                        }                    
                    }
                    
                    
                    var parameters = {
                        src: source,
                        expandedBufferTime: 2,
                        liveBufferTime: 12,
                        liveDynamicStreamingBufferTime: 14,
                        dvrBufferTime: 12,
                        dvrDynamicStreamingBufferTime: 14,
                        dynamicStreamBufferTime: 14,
                        autoPlay: true,
                        verbose: true,
                        controlBarAutoHide: "false",
                        controlBarPosition: "bottom",
                        scale: "exactfit"
                    };
                    
            
                    
                    // Escape the ampersands so any URL params pass through OSMF into Wowza
                    s = parameters['src'];
                    s = escape(s);
                    parameters['src'] = s; 
                   
                    var wmodeValue = "direct";
                    // var wmodeOptions = ["direct", "opaque", "transparent", "window"];
                    // if (parameters.hasOwnProperty("wmode"))
                    // {
                    //         if (wmodeOptions.indexOf(parameters.wmode) >= 0)
                    //         {
                    //                 wmodeValue = parameters.wmode;
                    //         }                            
                    //         delete parameters.wmode;
                    // }
                    
                    // Embed the player SWF:                    
                    swfobject.embedSWF(
                                        "http://mirror.cs50.net/live50/swf/StrobeMediaPlayback.swf"
                                        , "StrobeMediaPlayback"
                                        , 600
                                        , 360
                                        , "10.3.0"
                                        , "http://mirror.cs50.net/live50/swf/expressInstall.swf"
                                        , parameters
                                        , {
                                           allowFullScreen: "true",
                                           wmode: wmodeValue
                                          }
                                        , {
                                           name: "StrobeMediaPlayback"
                                          }
                                );
                    
                    /* Uncomment this code to be notified of playback errors in JavaScript: 
                    
                     function onMediaPlaybackError(playerId, code, message, detail)            
                     {
                             alert(playerId + "\n\n" + code + "\n" + message + "\n" + detail);            
                     }
                     
                     */
                 }

                 function get_raster(g)
                 {
                    if (!(typeof g.raster === "undefined" || g.raster == ""))
                    {
                        switch(g.raster)
                        {
                            case "720p":
                                $("#720p").parent().addClass("active");
                                $("#360p").parent().removeClass("active");
                                $("#160p").parent().removeClass("active");
                                break;
                            case "360p":
                                $("#720p").parent().removeClass("active");
                                $("#360p").parent().addClass("active");
                                $("#160p").parent().removeClass("active");
                                break;
                            case "160p":
                                $("#720p").parent().removeClass("active");
                                $("#360p").parent().removeClass("active");
                                $("#160p").parent().addClass("active");
                                break;
                            default:
                                return false;
                                break;
                        }
                        return g.raster;
                    }
                 }
                
            </script>
        
    </body>
</html>