Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web audio #1002

Closed
wants to merge 2 commits into from
Closed

Web audio #1002

wants to merge 2 commits into from

Conversation

webpro
Copy link

@webpro webpro commented Oct 10, 2014

See #986. This is the generic idea. Plenty of improvements possible, but I've just tried to stick with the current setup for the client-side application as much as possible.

Note that I've not considered any performance and (cross-browser) compatibility issues, so this should not be merged right away. I can do this later on, but wanted you/others to have a look at what I have now.

Let's discuss the idea, issues, and directions.

@sampsyo
Copy link
Member

sampsyo commented Oct 11, 2014

Cool! Thanks for taking the first step—this should be great to have.

Yes, we should check how this interacts with native playback. It would be a shame to lose that when the platform supports it.

I'm also somewhat wary about including these JavaScript components in the main beets distribution. I already regret including jQuery, for example, which seems to cause headaches for packagers. For example, in Debian, they need to unbundle these components and create dependencies on official JavaScript packages. They also can't accept minified/compiled JavaScript as it's not considered "source code".

I'm not sure what the best way around this is, but two non-ideal paths come to mind:

  • Eventually, I'd like to un-bundle the client from the web server plugin (see the larger effort in Extensible web plugin #718) so the browser stuff stays nicely separated from the Python stuff. No timeline on this, though.
  • Link to CDN-hosted versions of the dependencies. jQuery has this option, but I'm not sure Aurora.js does. The obvious drawback is that the interface can't be hosted entirely locally.

@webpro
Copy link
Author

webpro commented Oct 12, 2014

Yes, eventually we should use Aurora.js only as a fallback.

I wasn't aware of other efforts such you refer to. Perhaps a feasible road is along these lines:

  • Migrate to npm package (requires an npm install beets-player or something).
  • This web client runs in the browser.
  • Client consumes the current and/or new HTTP API.
  • Client can be built any way we like (no packaging issues). Install dependencies along with npm, and build with Browserify is convenient.
  • Client can use CORS or we include a simple Node.js server to proxy HTTP API.
  • Node.js can be used to serve the web client.

I think this is a great route for a (local) web client, but it would require npm.

@sampsyo
Copy link
Member

sampsyo commented Oct 12, 2014

Yeah, something like this would be good. We of course don't need to solve the whole problem right now just to get the Aurora.js feature, but I suppose it can't hurt!

#736 discusses the CORS/swappable frontend issue a little bit. CORS is probably the way to go, but another fallback (aside from a little node.js server or what have you) is to let the server itself host frontends. You could say beet serve --frontend /path/to/my/html or something to host a particular interface.

I am far from being a practiced front-end developer, but it seems like Bower could also be a good alternative for packaging these things. We could even provide "builds" that include snapshots of all the dependencies for easy npm-free installation.

@sampsyo
Copy link
Member

sampsyo commented Oct 12, 2014

To make a long comment shorter: I think a separate beets-player package is a great idea, even in the short term. Let's explore it!

@webpro
Copy link
Author

webpro commented Oct 13, 2014

Maybe it's useful to start with a migration of the existing web client (not the one in this PR) to a separate intermediate/legacy npm package, mostly to get a feel for how that would work and discussion. It would be served from the existing server with the example command you provided. That shouldn't be a lot of work.

I think a well-featured player, in a new fancy UI with native <audio> support, Aurora.js fallback, using the new HTTP API, and probably other features/changes should go into a new npm package. I'm happy to do some UI framework/development once the direction is clear on most of these fronts. I'll try to read the other threads when I have a chance.

@sampsyo
Copy link
Member

sampsyo commented Oct 13, 2014

Indeed—that would be a great experimental first step. I'll keep looking into it—and, meanwhile, I would be very interested to hear from more experienced frontend engineers about their favorite tools for doing stuff along these lines.

@webpro
Copy link
Author

webpro commented Oct 14, 2014

More input is definitely welcome. Any insights on how lightweight it should be? What devices should it run on? Desktop, mobile, anything else?

Btw, I do think that Bower isn't adding much over npm here (mostly because npm install bower).

@sampsyo
Copy link
Member

sampsyo commented Oct 14, 2014

Good question! The web interface works right now on iOS, but not particularly well. (I don't know about other platforms.) It would certainly be nice to keep that as an option… mobile-first world and all. 😃

I'll be the first to admit that I don't know the relative merits here, so you're probably right about npm vs Bower. My impression was that bower was focused on frontend stuff—HTML and CSS components, and JavaScript intended to run in the browser—while npm is supposed to contain Node.js libraries. But it appears the lines have gotten somewhat blurred.

@webpro
Copy link
Author

webpro commented Oct 21, 2014

Apologies for being a bit silent here. I'm willing to start building a frontend, but existing alternative frontends for Beets like Ampache (I didn't know of) look attractive at first sight (regardless of required integration efforts). I didn't really look around at all before, to be honest.

Imho, any efforts here should have some "unique selling points" (e.g. UI-wise), or other benefits to have a "dedicated" Beets frontend. Before starting any development, I'd like to know more about existing efforts and (potential) alternatives :-)

For starters:

Anything else? Reasons to not jump onto alternative frontends?

@sampsyo
Copy link
Member

sampsyo commented Oct 21, 2014

I've actually collected several of these. Everybody and their dog seems to want to write a browser-based music streamer:

The problem that I see with all of these efforts is that everyone invents their own protocol. This means that they have to solve two problems: the front-end interface and the back-end database. This coupling is problematic because both are hard problems! A developer who's excited about building a cool Web frontend (or even an iPhone streaming app?) should not get slowed down by needing to worry about the backend database.

Hence the effort toward a polished API that can separate these. I know this has shades of xkcd, but I think this a real vacuum: there is no good API worth reusing.

Fortunately, beets is in a good position to help solve this: we've done the hard work for the backend database; now we can use that to help expose the right API for frontend designers.

Anyway, I totally agree that it might be worth starting with one of these frontends—which are probably far further along than our little prototype—and extend it to use the API we expose. Maybe it's worth doing a survey to see which projects look suitable for integration.

@bearcatsandor
Copy link

Doesn't Ampache already have a beets catalog plugin? Couldn't that be used?

Bearcat M. Şándor
Feline Soul Systems LLC
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
On Oct 21, 2014 5:00 PM, "Adrian Sampson" [email protected] wrote:

I've actually collected several of these. Everybody and their dog seems to
want to write a browser-based music streamer:

The problem that I see with all of these efforts is that everyone invents
their own protocol. This means that they have to solve two problems: the
front-end interface and the back-end database. This coupling is problematic
because both are hard problems! A developer who's excited about building a
cool Web frontend (or even an iPhone streaming app?) should not get slowed
down by needing to worry about the backend database.

Hence the effort toward a polished API that can separate these. I know
this has shades of xkcd https://xkcd.com/927/, but I think this a real
vacuum: there is no good API worth reusing.

Fortunately, beets is in a good position to help solve this: we've done
the hard work for the backend database; now we can use that to help expose
the right API for frontend designers.

Anyway, I totally agree that it might be worth starting with one of these
frontends—which are probably far further along than our little
prototype—and extend it to use the API we expose. Maybe it's worth doing a
survey to see which projects look suitable for integration.


Reply to this email directly or view it on GitHub
#1002 (comment).

@sampsyo
Copy link
Member

sampsyo commented Oct 21, 2014

Doesn't Ampache already have a beets catalog plugin? Couldn't that be used?

Does it? A little googling hasn't turned that up… got a link?

@bearcatsandor
Copy link

I was looking at this:
http://zic.dmp.io/admin/modules.php?action=show_catalog_types , but this
looks like a live server so it may be something home-rolled.

On Tue, Oct 21, 2014 at 5:42 PM, Adrian Sampson [email protected]
wrote:

Doesn't Ampache already have a beets catalog plugin? Couldn't that be used?

Does it? A little googling hasn't turned that up… got a link?


Reply to this email directly or view it on GitHub
#1002 (comment).

Bearcat M. Şándor
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
My public pgp key is included for verification of my identity

@Afterster
Copy link

Yes it does :), in develop branch thanks to @Razrael and ampache/ampache#398
I'm following beets project since a long time and this specific thread since one week ; I'm the current Ampache project maintainer and also a daily beets user.
When I became Ampache maintainer last year, I had the same reflexion about the API and in that way added several backend support. Ampache can be configured to be accessed through regular Ampache API of course, but also Subsonic API, Plex API, UPnP and DACP protocols.
Sure it's great that Ampache support Beets, locally or remotely and this recent integration will match some beets user expectation. But I'm not sure you should integrate any complete solution.
First, Ampache is a PHP project ; that's said ;). Then all solution you listed including Ampache has a different project goal. Ampache will never try to do beets job and I think beets will become out of scope / heavy if you start adding Ampache / Subsonic / Mopidy ... functionalities. I also think you should only work on an API and for the web interface, focus on pure JS / HTML5 based client (See https://chrome.google.com/webstore/detail/ampache-player/fgmlgjpjedpnhbbpahgcknnjkhlbjhgp for Ampache, http://jamstash.com/ for Subsonic, or http://plex.tv for Plex).
Indeed Beets has a good position to define a new set of API, stronger/better than the other. But unless you have good technical reason or people willing to develop clients, don't do that. Previous Beets API didn't go far and only few software supported it. I myself didn't see any value to add Beets API backend to Ampache as we did for Subsonic/Plex/...
Subsonic main asset is the wide rang of clients, and those are extremely well developed. Their API : http://www.subsonic.org/pages/api.jsp. I will try to add Sindre Mehus (Subsonic project maintainer) to this discussion.

@bearcatsandor
Copy link

The thing that would make Beets integration awesome is all the tags that Beets can support. Just think of being able to filter a classical music collection by composer, or set up playlists based on bps or initial key. Being able to query our custom tags (i have one for who mastered the album and whether it's an original master recording). Starting a playlist based on a lead guitarist for all the songs she's been in regardless of band. I don't know of anything else but Beets integration that would do it easily. MPD doesn't track that stuff.

@RazielleS
Copy link

As I developed the first beets integration in ampache (local and over the web-plugin), I would be interested in a (better) API for both ways.
The web-plugin already has a JSON API, but it is not complete yet (I think). Missing album cover and maybe some tags (cannot look at this time).

For the local library I just made a wrapper for the CLI command and get all data via 'beet ls -f [way to many fields with some seperator]'. A JSON API or the possibility to get all data in JSON format would be great.

A solution for ampache to use all metadata for beets is on its way. I am developping the possibility to add custom metadata to ampache these days. When I am done with this, this will be of course also implemented to the beets catalogs.
One little problem is there: I discovered that when I use 'beets fields', I don't get the fields from the echo nest plugin. I guess this is the case because the fields are only in the beets DB and not in the files. But they should be in the fields list anyway I think.

@sampsyo
Copy link
Member

sampsyo commented Oct 22, 2014

Very cool! I'm excited to learn about this—I'll definitely have to try it out on my server. 😃

Your advice is heard loud and clear about making the web API complete for uses cases like this. I'm very interested in the v2 API being as complete as possible.

I also like the suggestion to provide a simple "local" version of the API that provides the same JSON responses on-demand through invocation. Hmm…

About beet fields:

One little problem is there: I discovered that when I use 'beets fields', I don't get the fields from the echo nest plugin.

This is actually because those are flexible attributes, which are not catalogued anywhere. They don't exist in the plugin, per se, they just exist on the albums and items they've been applied to. (This is different from computed fields, which plugins must explicitly declare, and which are shown in the beet fields output.)

That said, we could do a little better here by looking at the type declarations in the plugins, which do provide insight into the flexible attributes they "provide".

@sampsyo
Copy link
Member

sampsyo commented Oct 22, 2014

One more thought for the awesome Ampache people: I 100% agree about focusing on a REST API paired with purely client-side players. That's exactly what we'd like to accomplish here—and, in the process, get beets itself out of the business of providing the UI.

To that end, I'd be interested in collaborating with you (and perhaps also Sindre) on designing the right API to make life easy for clients. You obviously have lots of experience with emulating other APIs (Subsonic, Plex, UPnP, DACP), and I think we could learn a lot from that experience when designing an interoperable REST "standard". Let me know if you'd like to continue this conversation.

@Afterster
Copy link

I have some experience with several music/media api indeed. Each one have advantages/disadvantages, but there is no perfect one. My opinion would be to extend an existing api to have compatibility support with existing clients. I think you should first compare Ampache / Subsonic / UPnP / DACP api (Plex is not the best in your case because of all the myPlex stuff) on a feature level from a beets point of view. I'm willing to discuss this with you :)

@sampsyo
Copy link
Member

sampsyo commented Oct 25, 2014

@Afterster Thanks for the thoughts. I'll do a survey of the various APIs' features, and I will definitely be in touch again. As we put together a reasonable API, it would be awesome to have input from people with real experience building interfaces like Ampache.

@sampsyo
Copy link
Member

sampsyo commented Nov 1, 2014

To anyone who's interested: I've started putting together some ideas for a new API spec for this project. It's located in a different repository, and provisionally called AURA: https://github.com/sampsyo/aura

I'd be very interested to hear feedback on the direction from other project maintainers and anyone with experience in API design. You can see my notes on other projects' APIs on the wiki here: https://github.com/sampsyo/aura/wiki/Related-Work

@ab623
Copy link
Contributor

ab623 commented Dec 2, 2014

As a side note here, you mentioned the decoupling of beets and a web player which I think is the right way to go around doing it. In this instance, will beets also be providing the live transcoding of media file. I feel that if beets can query and serve media files, whilst transcoding to a web playable format or lower bit rate, will be a great feqature and a welcome addition.

@magne4000
Copy link

Hi, I'm working on a web player (festival) for several years now, and I would like to be able to use beets as the library.
I developed a subset of the subsonic API that, I think, could be easily ported to beets firstly (at least a piece of it).
I'll give it a shot.

@sampsyo
Copy link
Member

sampsyo commented Dec 15, 2016

Very nice! This player looks great. Maybe we should chat about the upcoming AURA API?

@magne4000
Copy link

@sampsyo You can find me as Magne` on Freenode

@magne4000
Copy link

Made a PR #2321

@webpro
Copy link
Author

webpro commented Sep 3, 2018

Sorry guys, no more activity (from my end), so I'm closing this issue.

@webpro webpro closed this Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants