Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to get the current playing file path? (Read 2560 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

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.


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 ?

 

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!