source: branches/fl5_instream/src/com/longtailvideo/jwplayer/events/MediaEvent.as @ 2040

Revision 2040, 13.7 KB checked in by pablo, 17 months ago (diff)

First pass at InStream API (644). Implements JavaScript API and Flash version

Line 
1package com.longtailvideo.jwplayer.events {
2        import flash.events.Event;
3
4        /**
5         * The MediaEvent class represents events related to media playback.
6         * 
7         * @see com.longtailvideo.media.MediaProvider
8         */
9        public class MediaEvent extends PlayerEvent {
10
11                /**
12             *  The <code>MediaEvent.JWPLAYER_MEDIA_BUFFER</code> constant defines the value of the
13         *  <code>type</code> property of the event object for a <code>jwplayerMediaBuffer</code> event.
14         *
15                 * <p>The properties of the event object have the following values:</p>
16             * <table class="innertable">
17         *              <tr><th>Property</th><th>Value</th></tr>
18             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
19             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
20             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
21             *          <tr><td><code>buffer</code></td><td>The percent of the media buffered into memory</td></tr>
22             *  </table>
23             *
24             *  @eventType jwplayerMediaBuffer
25                 */
26                public static var JWPLAYER_MEDIA_BUFFER:String = "jwplayerMediaBuffer";
27               
28                /**
29             *  The <code>MediaEvent.JWPLAYER_MEDIA_BUFFER_FULL</code> constant defines the value of the
30         *  <code>type</code> property of the event object for a <code>jwplayerMediaBufferFull</code> event.
31         *
32                 * <p>The properties of the event object have the following values:</p>
33             * <table class="innertable">
34         *              <tr><th>Property</th><th>Value</th></tr>
35             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
36             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
37             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
38             *          <tr><td><code>buffer</code></td><td>The percent of the media buffered into memory</td></tr>
39             *  </table>
40             *
41             *  @eventType jwplayerMediaBufferFull
42                 */
43                public static var JWPLAYER_MEDIA_BUFFER_FULL:String = "jwplayerMediaBufferFull";
44
45                /**
46             *  The <code>MediaEvent.JWPLAYER_MEDIA_ERROR</code> constant defines the value of the
47         *  <code>type</code> property of the event object for a <code>jwplayerMediaError</code> event.
48         *
49                 * <p>The properties of the event object have the following values:</p>
50             * <table class="innertable">
51         *              <tr><th>Property</th><th>Value</th></tr>
52             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
53             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
54             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
55             *          <tr><td><code>message</code></td><td>Message explaining the error.</td></tr>
56             *  </table>
57             *
58             *  @eventType jwplayerMediaError
59                 */
60                public static var JWPLAYER_MEDIA_ERROR:String = "jwplayerMediaError";
61
62                /**
63             *  The <code>MediaEvent.JWPLAYER_MEDIA_LOADED</code> constant defines the value of the
64         *  <code>type</code> property of the event object for a <code>jwplayerMediaLoaded</code> event.
65         *
66                 * <p>The properties of the event object have the following values:</p>
67             * <table class="innertable">
68         *              <tr><th>Property</th><th>Value</th></tr>
69             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
70             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
71             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
72             *  </table>
73             *
74             *  @eventType jwplayerMediaLoaded
75                 */
76                public static var JWPLAYER_MEDIA_LOADED:String = "jwplayerMediaLoaded";
77
78                /**
79             *  The <code>MediaEvent.JWPLAYER_MEDIA_COMPLETE</code> constant defines the value of the
80         *  <code>type</code> property of the event object for a <code>jwplayerMediaComplete</code> event.
81         *
82                 * <p>The properties of the event object have the following values:</p>
83             * <table class="innertable">
84         *              <tr><th>Property</th><th>Value</th></tr>
85             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
86             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
87             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
88             *  </table>
89             *
90             *  @eventType jwplayerMediaComplete
91                 */
92                public static var JWPLAYER_MEDIA_COMPLETE:String = "jwplayerMediaComplete";
93
94                /**
95                 *  The <code>MediaEvent.JWPLAYER_MEDIA_SEEK</code> constant defines the value of the
96                 *  <code>type</code> property of the event object for a <code>jwplayerMediaSeek</code> event.
97                 *
98                 * <p>The properties of the event object have the following values:</p>
99                 * <table class="innertable">
100                 *              <tr><th>Property</th><th>Value</th></tr>
101                 *              <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
102                 *              <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
103                 *              <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
104                 *              <tr><td><code>position</code></td><td>The current position of the media, in seconds.</td></tr>
105                 *              <tr><td><code>offset</code></td><td>The requested seek offset, in seconds.</td></tr>
106                 *  </table>
107                 *
108                 *  @eventType jwplayerMediaSeek
109                 */
110                public static var JWPLAYER_MEDIA_SEEK:String = "jwplayerMediaSeek";
111               
112                /**
113                 *  The <code>MediaEvent.JWPLAYER_MEDIA_TIME</code> constant defines the value of the
114                 *  <code>type</code> property of the event object for a <code>jwplayerMediaTime</code> event.
115                 *
116                 * <p>The properties of the event object have the following values:</p>
117                 * <table class="innertable">
118                 *              <tr><th>Property</th><th>Value</th></tr>
119                 *              <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
120                 *              <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
121                 *              <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
122                 *              <tr><td><code>position</code></td><td>Number of seconds elapsed since the start of the media playback.</td></tr>
123                 *              <tr><td><code>duration</code></td><td>Total number of seconds in the currently loaded media.</td></tr>
124                 *  </table>
125                 *
126                 *  @eventType jwplayerMediaTime
127                 */
128                public static var JWPLAYER_MEDIA_TIME:String = "jwplayerMediaTime";
129               
130                /**
131             *  The <code>MediaEvent.JWPLAYER_MEDIA_VOLUME</code> constant defines the value of the
132         *  <code>type</code> property of the event object for a <code>jwplayerMediaVolume</code> event.
133         *
134                 * <p>The properties of the event object have the following values:</p>
135             * <table class="innertable">
136         *              <tr><th>Property</th><th>Value</th></tr>
137             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
138             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
139             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
140             *          <tr><td><code>duration</code></td><td>The current playback volume, between 0 and 100.</td></tr>
141             *  </table>
142             *
143             *  @eventType jwplayerMediaVolume
144                 */
145                public static var JWPLAYER_MEDIA_VOLUME:String = "jwplayerMediaVolume";
146               
147                /**
148             *  The <code>MediaEvent.JWPLAYER_MEDIA_META</code> constant defines the value of the
149         *  <code>type</code> property of the event object for a <code>jwplayerMediaMeta</code> event.
150         *
151                 * <p>The properties of the event object have the following values:</p>
152             * <table class="innertable">
153         *              <tr><th>Property</th><th>Value</th></tr>
154             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
155             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
156             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
157             *          <tr><td><code>duration</code></td><td>The current playback volume, between 0 and 100.</td></tr>
158             *  </table>
159             *
160             *  @eventType jwplayerMediaMeta
161                 */
162                public static var JWPLAYER_MEDIA_META:String = "jwplayerMediaMeta";
163                /**
164                 * The MediaEvent.JWPLAYER_MEDIA_BEFOREPLAY constant defines the value of the
165                 * <code>type</code> property of the event object
166                 * for a <code>jwplayerMediaBeforePlay</code> event.
167                 *
168                 * <table class="innertable">
169                 *              <tr><th>Property</th><th>Value</th></tr>
170                 *              <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
171                 *              <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
172                 *              <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
173                 * </table>
174                 *
175                 * @eventType jwplayerMediaBeforePlay
176                 */
177                public static var JWPLAYER_MEDIA_BEFOREPLAY:String = "jwplayerMediaBeforePlay";
178                /**
179                 * The MediaEvent.JWPLAYER_MEDIA_BEFORECOMPLETE constant defines the value of the
180                 * <code>type</code> property of the event object
181                 * for a <code>jwplayerMediaBeforeComplete</code> event.
182                 *
183                 * <table class="innertable">
184                 *              <tr><th>Property</th><th>Value</th></tr>
185                 *              <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
186                 *              <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
187                 *              <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
188                 * </table>
189                 *
190                 * @eventType jwplayerMediaBeforePlay
191                 */
192                public static var JWPLAYER_MEDIA_BEFORECOMPLETE:String = "jwplayerMediaBeforeComplete";
193                /**
194             *  The <code>MediaEvent.JWPLAYER_MEDIA_MUTE</code> constant defines the value of the
195         *  <code>type</code> property of the event object for a <code>jwplayerMediaMute</code> event.
196         *
197                 * <p>The properties of the event object have the following values:</p>
198             * <table class="innertable">
199         *              <tr><th>Property</th><th>Value</th></tr>
200             *          <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr>
201             *          <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr>
202             *          <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr>
203             *          <tr><td><code>duration</code></td><td>The current playback volume, between 0 and 100.</td></tr>
204             *  </table>
205             *
206             *  @eventType jwplayerMediaMute
207                 */
208                public static var JWPLAYER_MEDIA_MUTE:String = "jwplayerMediaMute";
209
210                public var bufferPercent:Number         = -1;
211                public var duration:Number                      = -1;
212                public var metadata:Object                      = null;
213                public var position:Number                      = -1;
214                public var offset:Number                        = 0;
215                public var volume:Number                        = -1;
216                public var mute:Boolean                         = false;
217       
218                public function MediaEvent(type:String) {
219                        super(type);
220                }
221               
222                public override function clone():Event {
223                        var evt:MediaEvent = new MediaEvent(this.type);
224                        evt.bufferPercent = this.bufferPercent;
225                        evt.duration = this.duration;
226                        evt.metadata = this.metadata;
227                        evt.position = this.position;
228                        evt.offset = this.offset;
229                        evt.volume = this.volume;
230                        evt.mute = this.mute;
231                        return evt;
232                }
233               
234                public override function toString():String {
235                        var retString:String = '[MediaEvent type="' + type + '"';
236                        var defaults:MediaEvent = new MediaEvent("");
237
238                        for (var s:String in metadata) {
239                                retString += ' ' + s + '="' + metadata[s] + '"';
240                        }
241
242                        if (bufferPercent != defaults.bufferPercent) retString += ' bufferPercent="' + bufferPercent + '"';
243                        if (duration != defaults.duration) retString += ' duration="' + duration + '"';
244                        if (position != defaults.position) retString += ' position="' + position + '"';
245                        if (offset != defaults.offset) retString += ' offset="' + offset + '"';
246                        if (volume != defaults.volume) retString += ' volume="' + volume + '"';
247                        if (mute != defaults.mute) retString += ' mute="' + mute + '"';
248                        if (message != defaults.message) retString += ' message="' + message + '"';
249                       
250                        retString += ' id="' + id + '"'
251                        retString += ' client="' + client + '"'
252                        retString += ' version="' + version + '"'
253                        retString += "]";
254                       
255                        return retString;
256                }
257        }
258}
Note: See TracBrowser for help on using the repository browser.