Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
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
var strobeMediaPlayback = function () {
    /*var settings = {
        "tablet": {
            "startSize": {"width":480, "height":275}
        },
        "smartphone": {
            "startSize": {"width":120, "height":67}
        },
        "default": {
            "startSize": {"width":480, "height":275}
        }
    };*/
    
    //var flashvars = {};
    
    function getSettingByDeviceType(settings, setting, deviceType, defaultValue) {
        if (deviceType in settings) {
            return (settings[deviceType][setting] ? settings[deviceType][setting] : defaultValue);
        }
        else {
            return (settings["default"][setting] ? settings["default"][setting] : defaultValue);
        }
    }
    
    
    return { 
        /*settings: function(object) {
            settings = $.extend(true, settings, object);
        },
        flashvars: function(object) {
            flashvars = $.extend(true, flashvars, object);
        },*/
        draw: function(element, options, flashvars) {
            if (element && flashvars ) {
                var agent = window.location.hash.replace(/^#/, "");
                var settings = $.extend(true, settings, options);
                //function onDeviceDetection(device) {
                    var startSize = getSettingByDeviceType(settings, "startSize", device.getProfile().type, "");
                    var isDesktop = device.getProfile().type == "desktop"? true:false;
                    var flashPlayerVersion = swfobject.getFlashPlayerVersion();
                            var hasFlashPlayerCapability = flashPlayerVersion.major >= 10;  
                    if (device.profileDetected() && device.useFlash() && (hasFlashPlayerCapability && flashvars.favorFlashOverHtml5Video)) {
                        if (device.getProfile().type == "tablet" || device.getProfile().type == "smartphone"){
                            //flashvars.skin = "skins/"+device.getProfile().type+"-skin.xml";
                            flashvars.skin = "/CFIDE/scripts/ajax/resources/cf/skins/"+device.getProfile().type+"-skin.xml" 
                            flashvars.controlBarType = device.getProfile().type;
                            flashvars.playButtonOverlay = false;
                        }
                        var params = settings[(device.getProfile().type in settings ? device.getProfile().type : "default")];
                        params["movie"] = flashvars.swf;
                        params["allowfullscreen"] = "true";
                        params["allowscriptaccess"] = "always";
                        params["wmode"] = flashvars.wmode;
                        
                        var attributes = {};
                        $("#" + element).css("width",startSize["width"]);
                        $("#" + element).css("height",startSize["height"]);
                        var options = $.extend(true,options,  flashvars);
                        swfobject.embedSWF(
                            flashvars.swf, 
                            element, 
                            startSize["width"], 
                            startSize["height"], 
                            "10.1.0", 
                            "", 
                            options, 
                            params, 
                            attributes,
                            onFlashEmbedComplete
                        );
                        
                    }
                    else {
                        var html5divs;
                        if (isDesktop)
                        {
                            html5divs = '<div class="html5player">' + 
                                '<a class="playoverlay"></a>' +
                                '<div class="errorwindow"></div>';
                            if(flashvars["controlBarMode"] != "none")
                            {
                                html5divs += '<div class="controls">' +
                                    '<div class="icon playtoggle">Play/Pause</div>' +
                                    '<div class="timestamp current">0:00</div>' +
                                    '<div class="progress">' +
                                        '<a class="slider"></a>' +
                                        '<div class="tracks">' +
                                            '<div class="seeking"></div>' + 
                                            '<div class="played"></div>' +
                                            '<div class="buffered"></div>' +
                                        '</div>' +
                                    '</div>' +
                                    '<span class="timestamp separator">/</span>' +
                                    '<div class="timestamp duration">0:00</div>' +
                                    '<a class="icon volume high"></a>'+
                                    '<div class=volume-container>' +
                                    '<div class=volume-slider></div></div>'+
                                    '<div class="icon fullview">Full View</div>' +
                                '</div>';
                            }
                            html5divs += '<video id="' + flashvars["id"] + '"  width="' + startSize["width"] + '" height="' + startSize["height"] + '" preload="none" poster="' + flashvars["poster"] + '"';
                                if(flashvars["loop"])
                                    html5divs += " loop";
                                if(flashvars["autoPlay"])
                                    html5divs += " autoplay=\"autoplay\"";
                                html5divs +=">";
                                if(flashvars["src"])
                                    html5divs += '<source src="' + flashvars["src"] + '" />'
                                html5divs += '</video>'  + 
                            '</div>';
                        }else
                        {
                            html5divs = 
                            '<div class="html5player">' + 
                                '<div class="errorwindow"></div>';
                                if(flashvars["controlBarMode"] != "none")
                                {    
                                    html5divs += '<div class="controls">' +
                                        '<div class="icon playtoggle">Play/Pause</div>' +
                                        '<div class="timestamp current">0:00</div>' +
                                        '<div class="progress">' +
                                            '<a class="slider"></a>' +
                                            '<div class="tracks">' +
                                                '<div class="seeking"></div>' + 
                                                '<div class="played"></div>' +
                                                '<div class="buffered"></div>' +
                                            '</div>' +
                                        '</div>' +
                                        '<div class="timestamp duration">0:00</div>' +
                                        '<div class="icon fullview">Full View</div>' +
                                    '</div>' ;
                                }
                                html5divs += '<video id="' + flashvars["id"] + '"  width="' + startSize["width"] + '" height="' + startSize["height"] + '" poster="' + flashvars["poster"] + '"';
                                if(flashvars["loop"])
                                    html5divs += " loop";
                                html5divs +=">";
                                if(flashvars["src"])
                                    html5divs += '<source src="' + flashvars["src"] + '" />'
                                html5divs += '</video>'  + 
                            '</div>';
                        }
                        $("#" + element).html(html5divs);
                        //$("#" + element + " .html5player").strobemediaplaybackhtml5();
                    }
                //}
 
                //new DeviceDetection(agent).addCallback(onDeviceDetection).addProfiles(profiles).detect();
            }
        }
    }
}();