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: loading m3u8 via sdk (Read 3398 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

loading m3u8 via sdk

as a relatively new C++ progammer

how do i add an m3u8/m3u file to an existing playlist

im using

Code: [Select]
static_api_ptr_t<playlist_manager> plm;
metadb_handle_ptr handle;
static_api_ptr_t<metadb>()->handle_create(handle, make_playable_location(fileName, 0));
metadb_handle_list list;
list.add_item(handle);
plm->activeplaylist_add_items(list, bit_array_true());


to a a filename
now when fileName = "blabla.mp3" that adds into playlist
but when fileName = "blabal.m3u8" foo doesnt know thats a playlist and should be parse

id think there would be something in playlist_manager thant can help me
im a little confused even how to open a playlist
via playlist_loader, the callbacks confuse me, and i find NO sample code on this

thanks all

mitch


loading m3u8 via sdk

Reply #2
I tried just to see...

Code: [Select]
static_api_ptr_t<playlist_incoming_item_filter_v2> plf;
static_api_ptr_t<playlist_manager> plm;
metadb_handle_list list;

plf->process_location(item.toString(), list, false, NULL, NULL, NULL);

plm->activeplaylist_add_items(list, bit_array_true());


and item = "e:\test.m3u8"

and it did NOT process the PL

it added test.m3u8 to pl (which is invalid)

i think location should be a path, not a playlist file...

loading m3u8 via sdk

Reply #3
as foosion said, you need to take a different approach, something like this:

Code: [Select]
class process_locations_notify_my : public process_locations_notify {
public:
    void on_completion(const pfc::list_base_const_t<metadb_handle_ptr> & p_items)
    {
        static_api_ptr_t<playlist_manager> plm;
        plm->activeplaylist_add_items(p_items, bit_array_true());
    };

    void on_aborted() { };
};

service_ptr_t<process_locations_notify_my> notify = new service_impl_t<process_locations_notify_my>();
list_t<const char *> files;    // files/dirs to be added
static_api_ptr_t<playlist_incoming_item_filter_v2>()->process_locations_async(
            files,
            playlist_incoming_item_filter_v2::op_flag_background,
            NULL,
            "",
            core_api::get_main_window(),
            notify);

loading m3u8 via sdk

Reply #4
Ah... i was just trying a non Async version as a test

and that doesnt work too... it adds for example "test.m3u8" as a item into the playlist...
not actually opening the file, and parsing it for the mp3's inside

im sure this is possible.. when i DROP a m3u8 file on to fb2k, it parses it

loading m3u8 via sdk

Reply #5
essentially the same code works for me: test-case m3u8 was parsed properly.

loading m3u8 via sdk

Reply #6
If all you want to do is add the processed items to a playlist, you could also use a convenience method from the playlist_manager. See playlist_manager::playlist_add_locations.

If you see the M3U8 file in the playlist, then foobar2000 might not be able to parse your file path. Can you show us what the file path looks like?

 

loading m3u8 via sdk

Reply #7
AH!

i figured it out

it didnt like the path with the " around "

ie

"e:\test.m3u8"

e:\test.m3u8

ill strip off "

now i wonder if my 1st try would have worked 

thanks!