Changeset 1104 for trunk/fl5/doc/publishers/javascriptapi.rst
- Timestamp:
- 06/07/10 06:36:10 (3 years ago)
- File:
-
- 1 edited
-
trunk/fl5/doc/publishers/javascriptapi.rst (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fl5/doc/publishers/javascriptapi.rst
r1079 r1104 10 10 -------------- 11 11 12 Please note that the player will **NOT** be available the instant your H ML page is loaded and the first javascript is executed. The SWF file (40k) has to be loaded and instantiated first! You can catch this issue by defining a simple global javascript function. It is called *playerReady()* and every player that's succesfully instantiated will call it.12 Please note that the player will **NOT** be available the instant your HTML page is loaded and the first javascript is executed. The SWF file (90k) has to be loaded and instantiated first! You can catch this issue by defining a simple global javascript function. By default, it is called *playerReady()* and every player that's succesfully instantiated will call it. 13 13 14 14 .. code-block:: html … … 35 35 Plugin version and platform the player uses, e.g. *FLASH WIN 10.0.47.0*. 36 36 37 It is possible to ask the player to call a different javascript function after it completed its initialization. This can be done with an :ref:`option <options>` called **playerready**. Here is an example SWFObject :ref:` embed code <embedding>` using the function *registerPlayer()*: 38 39 .. code-block:: html 40 41 <p id="container1">You don't have Flash ...</p> 42 43 <script type="text/javascript"> 44 var flashvars = { file:'/data/bbb.mp4',playerready:'registerPlayer' }; 45 var params = { allowfullscreen:'true', allowscriptaccess:'always' }; 46 var attributes = { id:'player1', name:'player1' }; 47 swfobject.embedSWF('player.swf','container1','480','270','9.0.115','false', 48 flashvars, params, attributes); 49 50 var player; 51 function registerPlayer(obj) { 52 alert('The player with ID '+obj.id + 'is ready!'); 53 player = document.getElementById(obj.id); 54 }; 55 </script> 56 57 37 58 If you are not interested in calling the player when the page is loading, you won't need the *playerReady()* function. You can then simply use the ID of the embed/object tag that embeds the player to get a reference. So for example with this embed tag: 38 59 … … 49 70 .. note:: 50 71 51 Note you must add both the **id** and **name** attributes in the *<embed >* in order to get back an ID in all browsers.72 Note you must add both the **id** and **name** attributes in the *<embedding>* in order to get back an ID in all browsers. 52 73 53 74 … … 72 93 .. describe:: bandwidth 73 94 74 Current bandwidth of the player to the server, in kbps (e.g. *1431*). This is only available for videos, :ref:`http ` and :ref:`rtmp`.95 Current bandwidth of the player to the server, in kbps (e.g. *1431*). This is only available for videos, :ref:`httpstreaming` and :ref:`rtmpstreaming`. 75 96 76 97 .. describe:: fullscreen … … 88 109 .. describe:: level 89 110 90 Currently active bitrate level, in case multipe bitrates are supplied to the player. This is only useful for :ref:`http ` and :ref:`rtmp`. Note that *0* always refers to the highest quality bitrate.111 Currently active bitrate level, in case multipe bitrates are supplied to the player. This is only useful for :ref:`httpstreaming` and :ref:`rtmpstreaming`. Note that *0* always refers to the highest quality bitrate. 91 112 92 113 .. describe:: position … … 124 145 ^^^^^^^^^^^^^ 125 146 126 getPlaylist() returns the current playlist of the player as an array. Each entry of this array is in turn again a hashmap with all the :ref:`playlist properties <playlist s>` the player recognizes. Here's a few examples:147 getPlaylist() returns the current playlist of the player as an array. Each entry of this array is in turn again a hashmap with all the :ref:`playlist properties <playlistformats>` the player recognizes. Here's a few examples: 127 148 128 149 .. code-block:: html … … 133 154 alert("The poster image of the second entry is " + playlist[1].image); 134 155 alert("The media file of the third entry is " + playlist[2].file); 135 alert("The media type of the fourth entry is " + playlist[3].type);156 alert("The media provider of the fourth entry is " + playlist[3].provider); 136 157 137 158 … … 189 210 Seeking does not work if the player is in the *IDLE* state. Make sure to check the *state* variable before attempting to seek. 190 211 191 Additionally, for the *video* media type, the player can only seek to portions of the video that are already loaded. All other media types (*sound*, *image*, *youtube*, *http* and *rtmp* streaming)do not have this additional restriction.212 Additionally, for the *video* media :ref:`provider <mediaformats>`, the player can only seek to portions of the video that are already loaded. All other media providers do not have this additional restriction. 192 213 193 214 .. describe:: stop … … 208 229 In order to let javascript respond to player updates, you can assign listener functions to various events the player fires. An example of such event is the *volume* one, when the volume of the player is changed. The player will call the listener function with one parameter, a *key:value* populated object that contains more info about the event. 209 230 210 Both the *Model* and the *Controller* of the player's :ref:`MVC structure <architecture>`send events. You can subscribe to their events by resp. using the *addModelListener()* and *addControllerListener()* function. Here's a few examples:231 Both the *Model* and the *Controller* of the player's internal MVC structure send events. You can subscribe to their events by resp. using the *addModelListener()* and *addControllerListener()* function. Here's a few examples: 211 232 212 233 .. code-block:: html … … 236 257 ^^^^^^^^^^^^ 237 258 238 Here's an overview of all events the *Model* sends. Note that the data of every event contains the *id*, *version* and *client* parameters that are also sent on :ref:`playerReady () <api>`.259 Here's an overview of all events the *Model* sends. Note that the data of every event contains the *id*, *version* and *client* parameters that are also sent on :ref:`playerReady <javascriptapi>`. 239 260 240 261 .. describe:: error … … 246 267 .. describe:: loaded 247 268 248 Fired while the player is busy loading the currently playing media item. This event is never sent for :ref:`rtmp `, since that protocol does not preload content. Data:269 Fired while the player is busy loading the currently playing media item. This event is never sent for :ref:`rtmpstreaming`, since that protocol does not preload content. Data: 249 270 250 271 * *loaded* ( Number ): the number of bytes of the media file that are currently loaded. 251 272 * *total* ( Number ): the total filesize of the media file, in bytes. 252 * *offset* (Number): the byte position of the media file at which loading started. This is always 0, except when using :ref:`http `.273 * *offset* (Number): the byte position of the media file at which loading started. This is always 0, except when using :ref:`httpstreaming`. 253 274 254 275 .. describe:: meta … … 257 278 258 279 * *duration* ( Number) : sent for *video*, *youtube*, *http* and *rtmp* media. In seconds. 259 * *height* ( Number ): sent for all media types, except for *youtube*. In pixels.260 * *width* ( Number ): sent for all media types, except for *youtube*. In pixels.280 * *height* ( Number ): sent for all media providers, except for *youtube*. In pixels. 281 * *width* ( Number ): sent for all media providers, except for *youtube*. In pixels. 261 282 * Codecs, framerate, seekpoints, channels: sent for *video*, *http* and *rtmp* media. 262 283 * TimedText, captions, cuepoints: additional metadata that is embedded at a certain position in the media file. Sent for *video*, *http* and *rtmp* media. 263 * ID3 info (genre, name, artist, track, year, comment): sent for MP3 files (the *sound* media type).284 * ID3 info (genre, name, artist, track, year, comment): sent for MP3 files (the *sound* :ref:`media provider <mediaformats>`). 264 285 265 286 … … 285 306 ^^^^^^^^^^^^^^^^^ 286 307 287 Here's an overview of all events the *Controller* sends. Note that the data of every event contains the *id*, *version* and *client* parameters that are also sent on :ref:`playerReady () <api>`.308 Here's an overview of all events the *Controller* sends. Note that the data of every event contains the *id*, *version* and *client* parameters that are also sent on :ref:`playerReady <javascriptapi>`. 288 309 289 310 .. describe:: item
Note: See TracChangeset
for help on using the changeset viewer.
