Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

Minor enhancement request #58

Closed brianavid closed 8 years ago

brianavid commented 8 years ago

Can I request a new one-line method as an enhancement please in Session.cpp. I did this myself several months ago, but forgot to push it back. So when I updated through nuget, it has disappeared (not a surprise!).

The method is simply:

Link ^Session::GetLink(String ^link) {
    return Link::Create(this, link);
}

This means that if I have an externally provided Spotify link (e.g. from the Web API), I can find the track or album in order to play it. Is anyone (Aleksander, Chris) in a position to do this and push the build through to nuget??

Thanks

Brian

brianavid commented 8 years ago

And of course in the Session.h file:

virtual Link ^GetLink(String ^link) sealed;
Alxandr commented 8 years ago

I have no idea what it takes to get this project up and running anymore, as to what I need to install on my PC etc. If you want a new release pushed to nuget, send me a pull request with the changes. Include in the pull-request a version bump (IIRC, it's done by running the release script), and send me the resulting nuget package, and I can upload it for you.

brianavid commented 8 years ago

Thanks Aleksander,

I may do that later on. Though it sounds as though the project is winding down without future development, so it may not be worth it.

Meanwhile, I can (and will) use reflection in my calling code to cheat:

static Link GetLink(
    this Session session,
    String id)
{
    // Get Link.Create(Session,String)
    MethodInfo mInfo = typeof(Link).GetMethod(
        "Create",
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
        null,
        CallingConventions.Any,
        new Type[] { typeof(Session), typeof(String) },
        null);
    return mInfo?.Invoke(null, new object[] { session, id }) as Link;
}

It's not the best solution - GetLink() should be in the API. But it will do for now.

Alxandr commented 8 years ago

More like it's been wound down a long time ago. I plan to redo it in C# eventually. Though I have no idea when that eventuality will come.

brianavid commented 8 years ago

Moving off-topic, and looking to the future, any re-write probably can't use libspotify exclusively as SpotiFire does now. That API is no longer in active development and does not support more recent capabilities such as "My Music". All new capabilities are exposed through the Web API only.

It is for that reason that my own Spotify project (see https://www.youtube.com/watch?v=PSX-_iy29Pk) uses a mixture of web API for browsing and SpotiFire for play queue management and song playing through NAudio. That is why I need GetLink() - to get an externally provided album or track link into SpotiFire to queue it for playing.

But using the Web API introduces significant issues of authentication and traffic throttling. So it will not be easy!

eloekset commented 8 years ago

According to the Libspotify documentation, there will come a new library for "other platforms", which means other than iOS and Android.

2015-11-08_13-30-27
brianavid commented 8 years ago

The reflection idea was a non-starter - the non-public methods are not in the DLL :-(

Sent a pull-request with the new method added. Meanwhile I can use my private build

Alxandr commented 8 years ago

@brianavid Non-public methods are in the DLL, how else could they be used from within the code???

brianavid commented 8 years ago

That was my first thought. But in Link.h, Create() methods are in the internal: block and not emitted into the IL, so can't be found by reflection. But they are linked with Session.cpp in the DLL.

Alxandr commented 8 years ago

@brianavid They may be emitted as native methods, which can't be found by IL. Still strange though. Also, the new library which will come "later this year" (ie, late 2019) is probably a good point to rewrite SpotiFire again. The next one I plan to have xplat friendly (probably also CoreCLR).

brianavid commented 8 years ago

@Alxandr The use of reflection was not really a good idea anyway - I only tried it to save you the trouble of accepting the PR and uploading the nuget package. What we did eventually is by far the best outcome.

I am not holding my breath for any new APIs from Spotify. While libspotify is deprecated, it does seem to continue to work enough to serve track samples to an authenticated session within a custom player, which is all I need. That is a capability missing from the web API. The web API is great for browsing the catalog - and particularly "My Music". But the web API's authentication model is non-trivial to implement and I need to use a public URL on my web hosting to complete the handshake using my private key. I imagine that authentication in later APIs will be at least as tricky!

NeoLegends commented 8 years ago

The method has made it into the source, so this can be closed, right?

brianavid commented 8 years ago

Closed - yes