~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to lib/shadowbox-2.0/src/player/shadowbox-flv.js

  • Committer: Keith Hughitt
  • Date: 2010-02-17 22:00:59 UTC
  • mfrom: (402.1.68 hv)
  • Revision ID: keith.hughitt@nasa.gov-20100217220059-wmdq7kgokj4seryx
Merged with Keith's branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * The Shadowbox Flash video player class.
3
 
 *
4
 
 * This file is part of Shadowbox.
5
 
 *
6
 
 * Shadowbox is an online media viewer application that supports all of the
7
 
 * web's most popular media publishing formats. Shadowbox is written entirely
8
 
 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
9
 
 * authors can showcase a wide assortment of media in all major browsers without
10
 
 * navigating users away from the linking page.
11
 
 *
12
 
 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
13
 
 * Noncommercial-Share Alike license. This means that it is absolutely free
14
 
 * for personal, noncommercial use provided that you 1) make attribution to the
15
 
 * author and 2) release any derivative work under the same or a similar
16
 
 * license.
17
 
 *
18
 
 * If you wish to use Shadowbox for commercial purposes, licensing information
19
 
 * can be found at http://mjijackson.com/shadowbox/.
20
 
 *
21
 
 * @author      Michael J. I. Jackson <mjijackson@gmail.com>
22
 
 * @copyright   2007-2008 Michael J. I. Jackson
23
 
 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/
24
 
 * @version     SVN: $Id: shadowbox-flv.js 99 2008-05-11 16:22:43Z mjijackson $
25
 
 */
26
 
 
27
 
(function(){
28
 
 
29
 
    // shorthand
30
 
    var SB = Shadowbox;
31
 
    var SL = SB.lib;
32
 
 
33
 
    /**
34
 
     * Constructor. This class is used to display Flash videos with the JW
35
 
     * FLV player.
36
 
     *
37
 
     * @param   {String}    id      The id to use for this content
38
 
     * @param   {Object}    obj     The content object
39
 
     * @public
40
 
     */
41
 
    Shadowbox.flv = function(id, obj){
42
 
        this.id = id;
43
 
        this.obj = obj;
44
 
 
45
 
        // FLV's are resizable
46
 
        this.resizable = true;
47
 
 
48
 
        // height defaults to 300 pixels
49
 
        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
50
 
        if(SB.getOptions().showMovieControls == true){
51
 
            this.height += 20; // height of JW FLV player controller
52
 
        }
53
 
 
54
 
        // width defaults to 300 pixels
55
 
        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
56
 
    };
57
 
 
58
 
    Shadowbox.flv.prototype = {
59
 
 
60
 
        /**
61
 
         * Returns an object containing the markup for this content, suitable
62
 
         * to pass to Shadowbox.lib.createHTML().
63
 
         *
64
 
         * @param   {Object}    dims    The current Shadowbox dimensions
65
 
         * @return  {Object}            The markup for this content item
66
 
         * @public
67
 
         */
68
 
        markup: function(dims){
69
 
            var obj = this.obj;
70
 
 
71
 
            // use resized dimensions
72
 
            var h = dims.resize_h;
73
 
            var w = dims.resize_w;
74
 
 
75
 
            var options = SB.getOptions();
76
 
            var autoplay = String(options.autoplayMovies);
77
 
            var controls = options.showMovieControls;
78
 
            var showicons = String(controls);
79
 
            var displayheight = h - (controls ? 20 : 0); // subtract controller height
80
 
            var flashvars = [
81
 
                'file=' + this.obj.content,
82
 
                'height=' + h,
83
 
                'width=' + w,
84
 
                'autostart=' + autoplay,
85
 
                'displayheight=' + displayheight,
86
 
                'showicons=' + showicons,
87
 
                'backcolor=0x000000',
88
 
                'frontcolor=0xCCCCCC',
89
 
                'lightcolor=0x557722'
90
 
            ];
91
 
 
92
 
            return {
93
 
                tag:        'object',
94
 
                id:         this.id,
95
 
                name:       this.id,
96
 
                type:       'application/x-shockwave-flash',
97
 
                data:       options.flvPlayer,
98
 
                children:   [
99
 
                    { tag: 'param', name: 'movie', value: options.flvPlayer },
100
 
                    { tag: 'param', name: 'flashvars', value: flashvars.join('&amp;') },
101
 
                    { tag: 'param', name: 'allowfullscreen', value: 'true' }
102
 
                ],
103
 
                height:     h, // new height includes controller
104
 
                width:      w
105
 
            };
106
 
        },
107
 
 
108
 
        /**
109
 
         * Removes this movie from the document.
110
 
         *
111
 
         * @return  void
112
 
         * @public
113
 
         */
114
 
        remove: function(){
115
 
            var el = SL.get(this.id);
116
 
            if(el) SL.remove(el);
117
 
        }
118
 
 
119
 
    };
120
 
 
121
 
})();