Ignore:
Timestamp:
06/07/10 06:36:10 (3 years ago)
Author:
jeroen
Message:

rewritten playlists/mediaformats/options guides and fixed crosslinks, references to 'type' and pdf rendering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fl5/doc/publishers/javascriptapi.rst

    r1079 r1104  
    1010-------------- 
    1111  
    12 Please note that the player will **NOT** be available the instant your HML 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.  
     12Please 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.  
    1313 
    1414.. code-block:: html 
     
    3535  Plugin version and platform the player uses, e.g. *FLASH WIN 10.0.47.0*. 
    3636 
     37It 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 
    3758If 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: 
    3859 
     
    4970.. note::  
    5071 
    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. 
    5273 
    5374 
     
    7293.. describe:: bandwidth 
    7394 
    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`. 
    7596 
    7697.. describe:: fullscreen 
     
    88109.. describe:: level 
    89110 
    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. 
    91112 
    92113.. describe:: position 
     
    124145^^^^^^^^^^^^^ 
    125146 
    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 <playlists>` the player recognizes. Here's a few examples: 
     147getPlaylist() 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: 
    127148 
    128149.. code-block:: html 
     
    133154   alert("The poster image of the second entry is " + playlist[1].image); 
    134155   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); 
    136157 
    137158 
     
    189210      Seeking does not work if the player is in the *IDLE* state. Make sure to check the *state* variable before attempting to seek.  
    190211 
    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. 
    192213 
    193214.. describe:: stop 
     
    208229In 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. 
    209230 
    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: 
     231Both 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: 
    211232 
    212233.. code-block:: html 
     
    236257^^^^^^^^^^^^ 
    237258 
    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>`. 
     259Here'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>`. 
    239260 
    240261.. describe:: error 
     
    246267.. describe:: loaded 
    247268 
    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: 
    249270 
    250271   * *loaded* ( Number ): the number of bytes of the media file that are currently loaded. 
    251272   * *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`. 
    253274 
    254275.. describe:: meta 
     
    257278 
    258279   * *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. 
    261282   * Codecs, framerate, seekpoints, channels: sent for *video*, *http* and *rtmp* media. 
    262283   * 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>`). 
    264285 
    265286 
     
    285306^^^^^^^^^^^^^^^^^ 
    286307 
    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>`. 
     308Here'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>`. 
    288309 
    289310.. describe:: item 
Note: See TracChangeset for help on using the changeset viewer.