]> git.sesse.net Git - vlc/commitdiff
src/misc/vlm.c : export the current playlist item's index for each instance
authorAntoine Cellerier <dionoea@videolan.org>
Sun, 29 Jan 2006 14:26:57 +0000 (14:26 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 29 Jan 2006 14:26:57 +0000 (14:26 +0000)
share/http/* : display instances for vlm media elements
               some layout changes (inputs and outputs)

share/http/js/functions.js
share/http/js/vlm.js
share/http/requests/vlm.xml
src/misc/vlm.c

index 0e9b2bfd859316808fb85ca4246b8a1d1627e45f..f7fdb65d6c8b5e6988973610e624feb8a0622bdd 100644 (file)
@@ -58,7 +58,7 @@ function format_time( s )
 {
     var hours = Math.floor(s/3600);
     var minutes = Math.floor((s/60)%60);
-    var seconds = s%60;
+    var seconds = Math.floor(s%60);
     if( hours < 10 ) hours = "0"+hours;
     if( minutes < 10 ) minutes = "0"+minutes;
     if( seconds < 10 ) seconds = "0"+seconds;
index 58cfe397b78434054d0afe2d8479ba1af1acc354..f5ffb520d986568bd1d32f47cae804876d4ba417 100644 (file)
@@ -400,18 +400,11 @@ function parse_vlm_elements()
                     nb.appendChild( create_button( 'Delete', 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) );
 
                     var list = document.createElement( "ul" );
-                    /* begin input list */
-                    var inputs = elt.getElementsByTagName( 'input' );
-                    for( i = 0; i < inputs.length; i++ )
-                    {
-                        var item = document.createElement( "li" );
-                        item.appendChild( document.createTextNode( "Input: " + inputs[i].firstChild.data + " " ) );
-                        item.appendChild( create_button( "Delete", 'vlm_delete_input("' + elt.getAttribute( 'name' ) + '", '+(i+1)+' );' ) );
-                        list.appendChild( item );
-                    }
 
-                    /* Add input */
+                    /* begin input list */
                     var item = document.createElement( "li" );
+                    list.appendChild( item );
+                    item.appendChild( document.createTextNode( "Inputs: " ) );
                     var text = document.createElement( "input" );
                     text.setAttribute( 'type', 'text' );
                     text.setAttribute( 'size', '40' );
@@ -422,7 +415,20 @@ function parse_vlm_elements()
                     item.appendChild( document.createTextNode( ' ' ) );
                     item.appendChild( create_button( 'Add input', 'vlm_add_input("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_input").value );' ) );
                     
-                    list.appendChild( item );
+                    var inputs = elt.getElementsByTagName( 'input' );
+                    if( inputs.length > 0 )
+                    {
+                        var ilist = document.createElement( "ol" );
+                        ilist.setAttribute( 'start', '0' );
+                        item.appendChild( ilist );
+                        for( i = 0; i < inputs.length; i++ )
+                        {
+                            var item = document.createElement( "li" );
+                            item.appendChild( document.createTextNode( inputs[i].firstChild.data + " " ) );
+                            item.appendChild( create_button( "Delete", 'vlm_delete_input("' + elt.getAttribute( 'name' ) + '", '+(i+1)+' );' ) );
+                            ilist.appendChild( item );
+                        }
+                    }
                     /* end of input list */
                     
                     /* output */
@@ -452,17 +458,10 @@ function parse_vlm_elements()
                     /* end of output */
 
                     /* begin options list */
-                    var options = elt.getElementsByTagName( 'option' );
-                    for( i = 0; i < options.length; i++ )
-                    {
-                        var item = document.createElement( "li" );
-                        item.appendChild( document.createTextNode( "Option: " + options[i].firstChild.data ) );
-                        list.appendChild( item );
-                    }
-
-                    /* Add option */
                     var item = document.createElement( "li" );
-                    item.appendChild( document.createTextNode( ' ' ) );
+                    list.appendChild( item );
+                    item.appendChild( document.createTextNode( "Options: " ) );
+                    /* Add option */
                     var text = document.createElement( "input" );
                     text.setAttribute( 'type', 'text' );
                     text.setAttribute( 'size', '40' );
@@ -471,8 +470,47 @@ function parse_vlm_elements()
                     item.appendChild( document.createTextNode( ' ' ) );
                     item.appendChild( create_button( 'Add option', 'vlm_option("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_option").value );' ) );
                     
-                    list.appendChild( item );
+                    var options = elt.getElementsByTagName( 'option' );
+                    if( options.length > 0 )
+                    {
+                        var olist = document.createElement( "ul" );
+                        item.appendChild( olist );
+                        for( i = 0; i < options.length; i++ )
+                        {
+                            var item = document.createElement( "li" );
+                            item.appendChild( document.createTextNode( options[i].firstChild.data ) );
+                            olist.appendChild( item );
+                        }
+                    }
                     /* end of options */
+
+                    /* Instances list */
+                    var instances = elt.getElementsByTagName( 'instance' );
+                    if( instances.length > 0 )
+                    {
+                        var item = document.createElement("li");
+                        var ilist = document.createElement("ul");
+                        list.appendChild( item );
+                        item.appendChild(document.createTextNode("Instances:")); 
+                        item.appendChild( ilist );
+                        for( i = 0; i < instances.length; i++ )
+                        {
+                            var iname = instances[i].getAttribute( 'name' );
+                            var istate = instances[i].getAttribute( 'state' );
+                            var iposition = Number( instances[i].getAttribute( 'position' ) * 100);
+                            var itime = Math.floor( instances[i].getAttribute( 'time' ) / 1000000);
+                            var ilength = Math.floor( instances[i].getAttribute( 'length' ) / 1000000);
+                            var irate = instances[i].getAttribute( 'rate' );
+                            var ititle = instances[i].getAttribute( 'title' );
+                            var ichapter = instances[i].getAttribute( 'chapter' );
+                            var iseekable = instances[i].getAttribute( 'seekable' );
+                            
+                            var item = document.createElement( "li" );
+                            item.appendChild( document.createTextNode( iname + ": " + istate + " " + (iposition.toFixed(2)) + "%" + " " + format_time( itime ) + "/" + format_time( ilength ) ) );
+                            ilist.appendChild( item );
+                        }
+                    }
+                    /* end of instances list */
                     
                     nb.appendChild( list );
                     
index 96ca9c1630a73bac7fbe468103cf6940be5f457b..16a819a971a9f77c4876e4cd0d643b6c45fb1fb0 100644 (file)
@@ -41,7 +41,7 @@
       </options>
       <instances>
         <vlc id="foreach" param1="inst" param2="el.instances" />
-          <instance><vlc id="value" param1="inst"/></instance>
+          <instance name="<vlc id="value" param1="inst.name"/>" state="<vlc id="value" param1="inst.state"/>" position="<vlc id="value" param1="inst.position"/>" time="<vlc id="value" param1="inst.time"/>" length="<vlc id="value" param1="inst.length"/>" rate="<vlc id="value" param1="inst.rate"/>" title="<vlc id="value" param1="inst.title"/>" chapter="<vlc id="value" param1="inst.chapter"/>" seekable="<vlc id="value" param1="inst.seekable"/>" playlistindex="<vlc id="value" param1="inst.playlistindex"/>" />
         <vlc id="end" />
       </instances>
     </broadcast>
@@ -61,7 +61,7 @@
         </options>
       <instances>
         <vlc id="foreach" param1="inst" param2="el.instances" />
-          <instance><vlc id="value" param1="inst"/></instance>
+          <instance name="<vlc id="value" param1="inst.name"/>" state="<vlc id="value" param1="inst.state"/>" position="<vlc id="value" param1="inst.position"/>" time="<vlc id="value" param1="inst.time"/>" length="<vlc id="value" param1="inst.length"/>" rate="<vlc id="value" param1="inst.rate"/>" title="<vlc id="value" param1="inst.title"/>" chapter="<vlc id="value" param1="inst.chapter"/>" seekable="<vlc id="value" param1="inst.seekable"/>" playlistindex="<vlc id="value" param1="inst.playlistindex"/>" />
         <vlc id="end" />
       </instances>
       </vod>
index 10a728e3cea983196586671f6a32b7d3c710d184..bcfd1e9934c1e278313553151f27da200df0f51b 100644 (file)
@@ -1683,6 +1683,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
             APPEND_INPUT_INFO( "chapter", "%d", Integer );
             APPEND_INPUT_INFO( "seekable", "%d", Bool );
 #undef APPEND_INPUT_INFO
+            asprintf( &psz_tmp, "%d", p_instance->i_index );
+            vlm_MessageAdd( msg_instance, vlm_MessageNew( "playlistindex", psz_tmp ) );
+            free( psz_tmp );
             vlm_MessageAdd( msg_child, msg_instance );
         }