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: I need to add a URL location (Read 16651 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

I need to add a URL location

Essentially my code takes a URL generated from UPnP xml from a controller that is the path to the music file.
Most likely I will only ever be clearing the playlist and then adding a single file to Foobar2000.  then playing it etc.

Could I please get help with the code needed to do this?  I also need to pass that back to the main thread from my code.

Thank you

Darren

I need to add a URL location

Reply #1
My plugin gets a location from the network as a URL.  I just need to tell Foobar2000 to add this as a file for playback.  I am looking through the SDK and cannot find how to add a file for playing.

Please help.

Thank you

Darren

I need to add a URL location

Reply #2
The following code clears the active playlist and adds the tracks (possibly more than one) referred to by the given URL to it. It creates an undo point, so the user can revert to the previous playlist content. The select parameter controls if the new tracks will be selected. The parent window argument is needed for an eventual progress window; do not pass NULL for this! (core_api::get_main_window is an appropriate choice, if you do not have a window of your own.)

Code: [Select]
// Not tested, but should work.
void finding_a_better_name_for_this_function_is_left_as_an_exercise_for_the_reader(const char *url, bool select, HWND parentwnd)
{
    static_api_ptr_t<playlist_manager> pm;
    t_size playlist = pm->get_active_playlist(); // Use a different playlist if desired.

    pm->playlist_undo_backup(playlist); // Highly recommended unless you modify a locked, "smart" playlist (that you own)
    pm->playlist_clear(playlist); // If you want to replace the existing playlist content.
    pm->playlist_add_locations(
        playlist,
        pfc::list_single_ref_t<const char *>(url),
        select,
        parentwnd);
}

I need to add a URL location

Reply #3
Thank you .  I get this error when I try to build with it.


error LNK2001: unresolved external symbol __imp__StrCmpLogicalW@8

Darren

I need to add a URL location

Reply #4
You have to link your plugin with shlwapi.lib

I need to add a URL location

Reply #5
I dont know how to handle he HWND parentwnd

and could someone please tell me how to use abort_callback &p_abort

when I do this in the main_thread_callback

t_size playlist = pm->get_active_playlist();

I run my UPnP stack in another thread.  I am using main_thread_callback to control foobar2000, which works fine.

When I create a class for handling passing the URL to the main_thread_callback

static_api_ptr_t<main_thread_callback_manager> mtcm;
mtcm->add_callback(new service_impl_t<AVTOpen>(CurrentURI,true,handle));

The URI path gets destroyed inside the virtual void callback_run().

I don't have enough experience with class to fix this issue.

Also, how do I use the main_thread_callback to pass playback information (position etc) back to my thread?

please help

Thank you

Darren

EDIT:  Figured this out