diff --git a/modules/control/http.c b/modules/control/http.c index 1aeda59319523d7a78e807b61855c4c237e6b4ff..a3fd14e2ec9ee8b48894713775fa11ec1f682d00 100644 --- a/modules/control/http.c +++ b/modules/control/http.c @@ -870,8 +870,8 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg ) { int i; - if( ( i_start < i_stop && i_step > 0 ) || - ( i_start > i_stop && i_step < 0 ) ) + if( ( i_start <= i_stop && i_step > 0 ) || + ( i_start >= i_stop && i_step < 0 ) ) { for( i = i_start; ; i += i_step ) { @@ -897,31 +897,79 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg ) return s; } +void PlaylistListNode( playlist_t *p_pl, playlist_item_t *p_node, + char *name, mvar_t *s, int i_depth ) +{ + if( p_node != NULL ) + { + if (p_node->i_children == -1) + { + char value[512]; + mvar_t *itm = mvar_New( name, "set" ); + + sprintf( value, "%d", ( p_pl->status.p_item == p_node )? 1 : 0 ); + mvar_AppendNewVar( itm, "current", value ); + + sprintf( value, "%d", p_node->input.i_id ); + mvar_AppendNewVar( itm, "index", value ); + + mvar_AppendNewVar( itm, "name", p_node->input.psz_name ); + + mvar_AppendNewVar( itm, "uri", p_node->input.psz_uri ); + + sprintf( value, "Item"); + mvar_AppendNewVar( itm, "type", value ); + + sprintf( value, "%d", i_depth ); + mvar_AppendNewVar( itm, "depth", value ); + + mvar_AppendVar( s, itm ); + } + else + { + char value[512]; + int i_child; + mvar_t *itm = mvar_New( name, "set" ); + mvar_t *itm_end = mvar_New( name, "set" ); + + mvar_AppendNewVar( itm, "name", p_node->input.psz_name ); + mvar_AppendNewVar( itm, "uri", p_node->input.psz_name ); + + sprintf( value, "Node" ); + mvar_AppendNewVar( itm, "type", value ); + + sprintf( value, "%d", p_node->input.i_id ); + mvar_AppendNewVar( itm, "index", value ); + + sprintf( value, "%d", p_node->i_children); + mvar_AppendNewVar( itm, "i_children", value ); + + sprintf( value, "%d", i_depth ); + mvar_AppendNewVar( itm, "depth", value ); + + mvar_AppendVar( s, itm ); + + for (i_child = 0 ; i_child < p_node->i_children ; i_child++) + PlaylistListNode( p_pl, p_node->pp_children[i_child], name, s, i_depth + 1); + + } + } +} + static mvar_t *mvar_PlaylistSetNew( char *name, playlist_t *p_pl ) { mvar_t *s = mvar_New( name, "set" ); - int i; fprintf( stderr," mvar_PlaylistSetNew: name=`%s'\n", name ); vlc_mutex_lock( &p_pl->object_lock ); - for( i = 0; i < p_pl->i_size; i++ ) - { - mvar_t *itm = mvar_New( name, "set" ); - char value[512]; - sprintf( value, "%d", i == p_pl->i_index ? 1 : 0 ); - mvar_AppendNewVar( itm, "current", value ); + playlist_view_t *p_view; + p_view = playlist_ViewFind( p_pl, VIEW_CATEGORY ); /* FIXME */ - sprintf( value, "%d", i ); - mvar_AppendNewVar( itm, "index", value ); + if( p_view != NULL ) + PlaylistListNode( p_pl, p_view->p_root, name, s, 0 ); - mvar_AppendNewVar( itm, "name", p_pl->pp_items[i]->input.psz_name ); - - mvar_AppendNewVar( itm, "uri", p_pl->pp_items[i]->input.psz_uri ); - - mvar_AppendVar( s, itm ); - } vlc_mutex_unlock( &p_pl->object_lock ); return s; @@ -1416,6 +1464,7 @@ enum macroType MVLC_FOREACH, MVLC_IF, MVLC_RPN, + MVLC_STACK, MVLC_ELSE, MVLC_END, MVLC_GET, @@ -1469,6 +1518,7 @@ StrToMacroTypeTab [] = { "vlm_save", MVLC_VLM_SAVE }, { "rpn", MVLC_RPN }, + { "stack", MVLC_STACK }, { "foreach", MVLC_FOREACH }, { "value", MVLC_VALUE }, @@ -1561,8 +1611,9 @@ static void MacroDo( httpd_file_sys_t *p_args, uri_extract_value( p_request, "item", item, 512 ); i_item = atoi( item ); - playlist_Control( p_sys->p_playlist, PLAYLIST_GOTO, - i_item ); + playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY, + playlist_ItemGetById( p_sys->p_playlist, + i_item ) ); msg_Dbg( p_intf, "requested playlist item: %i", i_item ); break; } @@ -1877,24 +1928,15 @@ static void MacroDo( httpd_file_sys_t *p_args, i_nb_items++; } - /* The items need to be deleted from in reversed order */ if( i_nb_items ) { int i; for( i = 0; i < i_nb_items; i++ ) { - int j, i_index = 0; - for( j = 0; j < i_nb_items; j++ ) - { - if( p_items[j] > p_items[i_index] ) - i_index = j; - } - - playlist_LockDelete( p_sys->p_playlist, - p_items[i_index] ); + playlist_LockDelete( p_sys->p_playlist, p_items[i] ); msg_Dbg( p_intf, "requested playlist delete: %d", - p_items[i_index] ); - p_items[i_index] = -1; + p_items[i] ); + p_items[i] = -1; } } @@ -1920,17 +1962,17 @@ static void MacroDo( httpd_file_sys_t *p_args, i_nb_items++; } - /* The items need to be deleted from in reversed order */ - for( i = p_sys->p_playlist->i_size - 1; i >= 0 ; i-- ) + for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- ) { /* Check if the item is in the keep list */ for( j = 0 ; j < i_nb_items ; j++ ) { - if( p_items[j] == i ) break; + if( p_items[j] == + p_sys->p_playlist->pp_items[i]->input.i_id ) break; } if( j == i_nb_items ) { - playlist_LockDelete( p_sys->p_playlist, i ); + playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id ); msg_Dbg( p_intf, "requested playlist delete: %d", i ); } @@ -1949,25 +1991,38 @@ static void MacroDo( httpd_file_sys_t *p_args, { char type[12]; char order[2]; + char item[512]; int i_order; + int i_item; uri_extract_value( p_request, "type", type, 12 ); uri_extract_value( p_request, "order", order, 2 ); + uri_extract_value( p_request, "item", item, 512 ); + i_item = atoi( item ); if( order[0] == '0' ) i_order = ORDER_NORMAL; else i_order = ORDER_REVERSE; if( !strcmp( type , "title" ) ) { - playlist_SortTitle( p_sys->p_playlist , i_order ); + playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ + p_sys->p_playlist->pp_views[0]->p_root, + SORT_TITLE_NODES_FIRST, + ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order ); } else if( !strcmp( type , "author" ) ) { - playlist_SortAuthor( p_sys->p_playlist , i_order ); + playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ + p_sys->p_playlist->pp_views[0]->p_root, + SORT_AUTHOR, + ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order ); } else if( !strcmp( type , "shuffle" ) ) { - playlist_Sort( p_sys->p_playlist , SORT_RANDOM, ORDER_NORMAL ); + playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ + p_sys->p_playlist->pp_views[0]->p_root, + SORT_RANDOM, + ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist shuffle"); } @@ -2262,6 +2317,16 @@ static void MacroDo( httpd_file_sys_t *p_args, EvaluateRPN( p_args->vars, &p_args->stack, m->param1 ); break; +/* Usefull for learning stack management */ + case MVLC_STACK: + { + int i; + msg_Dbg( p_intf, "stack" ); + for (i=0;i<(&p_args->stack)->i_stack;i++) + msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] ); + break; + } + case MVLC_UNKNOWN: default: PRINTS( "<!-- invalid macro id=`%s' -->", m->id ); @@ -2921,6 +2986,10 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) { SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 ); } + else if( !strcmp( s, "!=" ) ) + { + SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 ); + } else if( !strcmp( s, "<" ) ) { int j = SSPopN( st, vars ); diff --git a/share/http/cone_minus.png b/share/http/cone_minus.png new file mode 100644 index 0000000000000000000000000000000000000000..b7a75e77aeb2047b30a8348fff29c07dd5337d8a Binary files /dev/null and b/share/http/cone_minus.png differ diff --git a/share/http/cone_plus.png b/share/http/cone_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..d093904ef65cc16f62bad3a2b9bdc349cc7d574f Binary files /dev/null and b/share/http/cone_plus.png differ diff --git a/share/http/index.html b/share/http/index.html index 4e40a713a49253b28579192b52a15208c7365975..fedc2c657e4561433a86ca39615c26c469818bb7 100644 --- a/share/http/index.html +++ b/share/http/index.html @@ -7,17 +7,31 @@ <title>VLC media player</title> <link href="/style.css" title="Default" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> - - <vlc id="if" param1="url_param"/> - <meta http-equiv="refresh" content="0;URL=/" /> - <vlc id="end" /> - <vlc id="control" param1="stop,pause,previous,next,add,sout,play,delete,empty,seek,fullscreen,keep,volume,sort,move" /> <vlc id="set" param1="sout" param2="string" /> - </head> +<script type="text/javascript"> - <body> +function changeMe(item) +{ + if (item.parentNode.parentNode.lastChild.style.display=="none") + { + item.parentNode.parentNode.lastChild.style.display="block"; + item.alt="[-]"; + item.src="cone_minus.png"; + } + else + { + item.parentNode.parentNode.lastChild.style.display="none"; + item.alt="[+]"; + item.src="cone_plus.png"; + } +} +</script> + +</head> + + <body> <!-- left menu --> <div class="left"> <div class="sectitle">Playback control</div> @@ -90,78 +104,81 @@ </div> <div class="section"> - <table> - <tr> - <td> - <table> - <tr> - <td> - <form method="get" action=""> - <input type="submit" name="control" value="sort" /> by - <select name="type"> - <option value="title">title</option> - <option value="group">group</option> - <option value="author">author</option> - <option value="shuffle">shuffle</option> - </select> with - <select name="order"> - <option value="0">normal order</option> - <option value="1">reverse order</option> - </select> - </form> - </td> - <td> - <form method="get" action=""> - Move the item number - <input type="text" name="psz_pos" size="5" /> to - <input type="text" name="psz_newpos" size="5" /> - <input type="submit" name="control" value="move" /> - </form> - </td> - </tr> - </table> - </td> - </tr> - <tr> - <td> - <form method="get" action=""> - <table> - <vlc id="rpn" param1="0"/> - <vlc id="foreach" param1="pl" param2="playlist" /> - <tr class="<vlc id="if" param1="pl.index 2 % 0 =" />line1<vlc id="else" />line2<vlc id="end" />"> - <td> - <input type="checkbox" name="item" value="<vlc id="value" param1="pl.index" />"/> - <vlc id="if" param1="pl.current" /> - <strong> - <vlc id="end" /> - <a href="?control=play&item=<vlc id="value" param1="pl.index" />"> - <vlc id="value" param1="pl.index" /> - <vlc id="value" param1="pl.uri" /><vlc id="if" param1="pl.uri value pl.name value strcmp"/> (<vlc id="value" param1="pl.name" />)<vlc id="end"/></a> - <vlc id="if" param1="pl.current" /> - </strong> - <vlc id="end" /> - </td> - </tr> - <vlc id="rpn" param1="1 +"/> - <vlc id="end" /> - <vlc id="if" param1="0 ="/> - <tr class="ligne1"> - <td>empty playlist</td> - </tr> - <vlc id="end"/> - </table> - <input type="submit" name="control" value="delete" /> - <input type="submit" name="control" value="keep" /> - </form> - </td> - </tr> - </table> + <form method="get" action=""> + <ul id="playlist"> + <vlc id="rpn" param1="first_item 0 store" /> + <vlc id="rpn" param1="last_depth 0 store" /> + <vlc id="foreach" param1="pl" param2="playlist" /> + <vlc id="if" param1="pl.depth value last_depth value <" /> + <vlc id="rpn" param1="pl.depth value ':' last_depth value 1 - ':' 1 strcat strcat strcat strcat" /> + <vlc id="foreach" param1="the_final_countdown" param2="integer" /> + </ul></li> + <vlc id="end" /> + <vlc id="end" /> + + <vlc id="if" param1="pl.type value 'Node' strcmp" /> + <vlc id="rpn" param1="1 +" /> + <li> + <input type="checkbox" name="item" value="<vlc id="value" param1="pl.index" />"/> + <vlc id="if" param1="pl.current" /> + <strong> + <vlc id="end" /> + <a href="?control=play&item=<vlc id="value" param1="pl.index" />"> + <vlc id="value" param1="pl.name" /><vlc id="if" param1="pl.uri value pl.name value strcmp"/> (<vlc id="value" param1="pl.uri" />)<vlc id="end"/></a> + <vlc id="if" param1="pl.current" /> + </strong> + <vlc id="end" /> + </li> + <vlc id="else" /> + <li> + <form method="get" action=""> + <img alt="[-]" src="cone_minus.png" onclick='changeMe(this)'/> + <vlc id="if" param1="first_item value 0 ="/> + Playlist + <vlc id="rpn" param1="first_item 1 store" /> + <vlc id="else"/> + <vlc id="value" param1="pl.name" /> (<vlc id="value" param1="pl.i_children" /> item<vlc id="if" param1="pl.i_children 1 >" />s<vlc id="end" />) + <vlc id="end"/> + <input type="hidden" name="item" value="<vlc id="value" param1="pl.index" />" /> + <input type="submit" name="control" value="sort" /> by + <select name="type"> + <option value="title">title</option> + <option value="shuffle">shuffle</option> + </select> with + <select name="order"> + <option value="0">normal order</option> + <option value="1">reverse order</option> + </select> + </form> + + <vlc id="if" param1="pl.i_children 0 !=" /> + <ul> + <vlc id="else" /> + </li> + <vlc id="end" /> + + <vlc id="end" /> + + <vlc id="rpn" param1="last_depth pl.depth value store" /> + + <vlc id="end" /> + <vlc id="rpn" param1="0 ':' last_depth value 1 - ':' 1 strcat strcat strcat strcat" /> + <vlc id="foreach" param1="the_final_countdown" param2="integer" /> + </ul></li> + <vlc id="end" /> + + </ul> + <input type="submit" name="control" value="delete" /> + <input type="submit" name="control" value="empty" /> + <input type="submit" name="control" value="keep" /> + </form> </div> </div> <!-- end main content --> <p style="text-align:center;font-size:1.2em;"> <vlc id="value" param1="copyright" /> </p> - <script language="javascript" type="text/javascript"> + <script type="text/javascript"> got_time = <vlc id="value" param1="stream_time" />; hours = Math.floor(got_time/ 3600); minutes = Math.floor((got_time/60) % 60); diff --git a/share/http/style.css b/share/http/style.css index b20b5d8a48bb69c749d16515adcc4f8ee05734ee..9f3d4a13115d3515ade49c6c37e6f50113e1b2b1 100644 --- a/share/http/style.css +++ b/share/http/style.css @@ -88,3 +88,7 @@ form { margin: 0pt; padding: 0pt; } + +ul#playlist, ul#playlist ul{ + list-style-type: none; +}