doc/integration.en.md
changeset 944 8a6c9e3d0158
parent 929 a39ff507b050
child 947 ec4e9ddf9fba
equal deleted inserted replaced
907:27b248a13355 944:8a6c9e3d0158
       
     1 # Integrating the Metadataplayer in an HTML page #
       
     2 
       
     3 WARNING !
       
     4 This documentation refers to version 0.3 of Metadataplayer, now available under the **new-model** branch in our repository
       
     5 http://www.iri.centrepompidou.fr/dev/hg/metadataplayer
       
     6 
       
     7 ## Loading the script ##
       
     8 
       
     9 The *LdtPlayer-core.js* must be declared in the HTML header.
       
    10 
       
    11     <head>
       
    12         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
       
    13         <title>Metadataplayer integration test</title>
       
    14         <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js" type="text/javascript"></script>
       
    15     </head>
       
    16 
       
    17 ## Declaration of a container HTML element ##
       
    18 
       
    19     <body>
       
    20         <div id="Metadataplayer"></div>
       
    21 
       
    22 The script for configuring and loading the Metadataplayer must be executed after this element is declared either by :
       
    23     - Adding a <*script*> element at the bottom of the page
       
    24     - Using an event such as *body.onload*
       
    25     - Using jQuery's *$(function(){})* syntax or an equivalent in your favorite framework
       
    26 
       
    27     <script type="text/javascript">
       
    28 
       
    29 ## Interface language configuration ##
       
    30 
       
    31 Language is defined ISO 639-1 (e.g., "es" pour l’Espagnol, "ja" pour le Japonais, "eu" pour le Basque). As of July 2012, only English ("en") and French ("fr") are available.
       
    32 
       
    33     IriSP.language = "fr";
       
    34 
       
    35 ## Library location configuration ##
       
    36 
       
    37 By default (as defined in *defaults.js*), librairies are loaded from either a CDN (Content Distribution Network) or from the *js/libs* directory.
       
    38 
       
    39 Configuration is done by overriding the properties of *IriSP.libFiles*
       
    40 
       
    41 To use the CDN:
       
    42 
       
    43     IriSP.libFiles.useCdn = true;
       
    44 
       
    45 To change the location of the library directory:
       
    46 
       
    47     IriSP.libFiles.defaultDir = "/path/libs";
       
    48 
       
    49 To change individual locations or to point to files outside the default directory:
       
    50 
       
    51     IriSP.libFiles.locations.jQueryUI = "libs/jquery-ui-1.8.16.custom.min.js";
       
    52     IriSP.libFiles.locations.jwPlayerSWF = "libs/jwplayer/player.swf";
       
    53 
       
    54 ## Configuration of metadata source ##
       
    55 
       
    56 A metadata source is defined by its url and file type (which defines the *serializer* to use).
       
    57 
       
    58 Example:
       
    59 
       
    60     var metadataSource = {
       
    61         url: "data/mydata.json",
       
    62         type: "ldt"
       
    63     };
       
    64 
       
    65 Metadata sources are then used to configure both the video player and the widgets.
       
    66 
       
    67 ## Configuration of the video player ##
       
    68 
       
    69 The video player is configured through an object having the following properties:
       
    70 
       
    71 - **metadata**: Metadata source.
       
    72 - **type**: Video player type :
       
    73     - **"jwplayer"**: Uses flash-based jwPlayer, compatible with many video and audio formats, including MP3 audio, MP4 video and RTMP streams.
       
    74     - **"html5"**: Uses the Popcorn.js library to play HTML5 videos. Supported formats : OGG and WebM on Firefox and Chrome, H.264 on Internet Explorer, Safari and Chrome.
       
    75     - **"youtube"**: Uses Popcorn's Youtube plugin.
       
    76     - **"dailymotion"**
       
    77     - **"auto"**: Replaced by *Youtube* or *Dailymotion* for a video hosted on one of these platform, or *jwPlayer* in other cases.
       
    78 - **width** and **height** of the video player.
       
    79 - **video**: Video URL. Optional: If present, it overrides the video URL defined in the metadata source.
       
    80 - Player-specific options, such as **provider** or **streamer** for JwPlayer
       
    81 
       
    82 Example:
       
    83 
       
    84     var playerConfig = {
       
    85         metadata: metadataSource,
       
    86         type: "jwplayer",
       
    87         height: 350,
       
    88         width: 620,
       
    89         provider: "rtmp"
       
    90     };
       
    91 
       
    92 ## User Interface Configuration ##
       
    93 
       
    94 L’interface se configure par un objet GUI, contenant les propriétés suivantes:
       
    95 
       
    96 - **container**: l’ID de l’élément HTML dans lequel le player sera instancié.
       
    97 - **width** et **height**: largeur et hauteur de l’interface (*height* est optionnel).
       
    98 - **default\_options**: des options de configuration communes à tous les widgets, par exemple, comme ci-dessous, une source de métadonnées communes.
       
    99 - **css**: l’URL du fichier CSS de base (LdtPlayer-core.css)
       
   100 - **widgets**: la liste des widgets, sous la forme [ { type: *Type du widget*, option_1: *Valeur de l’option 1* } ]. Pour les options des widgets, se référer au document *Architecture générale*
       
   101 
       
   102 Exemple:
       
   103 
       
   104     var guiConfig = {
       
   105         container : "Metadataplayer",
       
   106         default_options: {
       
   107             metadata: metadataSource
       
   108         },
       
   109         css : "metadataplayer/css/LdtPlayer-core.css",
       
   110         widgets: [
       
   111             {
       
   112                 type: "Slider"
       
   113             },{
       
   114                 type: "Controller",
       
   115                 disable\_annotate\_btn: true
       
   116             },{
       
   117                 type: "Segments",
       
   118                 annotation\_type: "Chapters"
       
   119             },{
       
   120                 type: "AnnotationsList",
       
   121                 container: "AnnotationsListContainer"
       
   122             }
       
   123         ]
       
   124     };
       
   125 
       
   126 ## Instanciation du player ##
       
   127 
       
   128 Le player s’instancie en créant un objet de type **IriSP.Metadataplayer**.
       
   129 
       
   130 Exemple:
       
   131 
       
   132     var config = {
       
   133         player: playerConfig,
       
   134         gui: guiConfig
       
   135     };
       
   136     var monPlayer = new IriSP.Metadataplayer(config);