{
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 )
{
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;
MVLC_FOREACH,
MVLC_IF,
MVLC_RPN,
+ MVLC_STACK,
MVLC_ELSE,
MVLC_END,
MVLC_GET,
{ "vlm_save", MVLC_VLM_SAVE },
{ "rpn", MVLC_RPN },
+ { "stack", MVLC_STACK },
{ "foreach", MVLC_FOREACH },
{ "value", MVLC_VALUE },
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;
}
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;
}
}
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 );
}
{
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");
}
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 );
{
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 );
<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>
</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);