Skip to main content

Topic: How to get the current playing file path? (Read 1459 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • lowzoom
  • [*]
How to get the current playing file path?
Which api can I use to get the playing file info such as its path ?
A snippet of code sample will be greatly appreciated !
Thx.

  • foosion
  • [*][*][*][*][*]
  • Moderator
How to get the current playing file path?
Reply #1
See playback_control::get_now_playing() and metadb_handle::get_path(). There are also the examples in the foobar2000 SDK and my component tutorial.
http://foosion.foobar2000.org/ - my components for foobar2000

  • lowzoom
  • [*]
How to get the current playing file path?
Reply #2
See playback_control::get_now_playing() and metadb_handle::get_path(). There are also the examples in the foobar2000 SDK and my component tutorial.

Thanks for your answer and your great tutorial, which're very helpful !!  ( And so are the sdk comments )

I have achieved what I want but there's one thing left which I'm not sure I've done correctly ( or elegantly ).
It's about removing an item from a playlist.

I can't find an api for removing a single item.
Instead I find one - playlist_remove_items() - which can remove items ( of course including a item ).

So I use it to remove an item in a playlist like this:

Code: [Select]
    t_size list_idx; // playlist index, assinged somewhere before
    t_size item_idx; // item index being removed, assinged somewhere before

    static_api_ptr_t<playlist_manager> list;
    int item_count = list->playlist_get_item_count(list_idx);
    t_size* list_bit = new t_size[item_count];
    for (int i=0; i<item_count; ++i)
        list_bit[i] = i;
    list_bit[item_idx] = -1;
    list->playlist_remove_items(list_idx, bit_array_wrapper_permutation(list_bit, item_count));
    delete [] list_bit;

It looks, however, so verbose and inefficient...
Is there a better way to remove an item in a playlist ?
  • Last Edit: 31 October, 2011, 11:06:28 AM by lowzoom

  • lowzoom
  • [*]
How to get the current playing file path?
Reply #3
Well... I kept reading the sdk source and finally found a right way(at least much better than the one above) to do it:

Code: [Select]
list->playlist_remove_items(list_idx, bit_array_one(item_idx));

Cheers! 
  • Last Edit: 31 October, 2011, 08:18:10 PM by lowzoom