tsquillario / Jamstash

HTML5 Music Streamer for Subsonic
http://jamstash.com
273 stars 87 forks source link

FLAC streaming not working #225

Open jcharaoui opened 9 years ago

jcharaoui commented 9 years ago

It would seem Chrome now supports playing FLAC through the HTML5 audio element, which I confirmed using various tests on the web. However, if I disable FLAC->MP3 transcoding on my Subsonic server, Jamstash won't play any FLAC files. It adds them to the queue but the playback progress bar on the bottom never appears. Furthermore, looking at my Subsonic server logs, it doesn't look like the server ever gets a request from the web app for the FLAC audio file.

Etuldan commented 9 years ago

For other browsers which doesn't support the Flac as audio source (like Firefox ?), maybe an integration of https://github.com/audiocogs/flac.js (GPL) could handle it ? (the subsonic server send the audio as flac, the browser, with the Jamstash frontend decode it with the JS API)

I found Jamstash a very interesting as audio player, and when I'm on the same network as my subsonic server, I'll enjoy the playing as lossless media

jcharaoui commented 9 years ago

I was able to enable FLAC support in Jamstash using the following patch:

diff --git a/app/player/player-directive.js b/app/player/player-directive.js
index 65ccc31..6a38603 100644
--- a/app/player/player-directive.js
+++ b/app/player/player-directive.js
@@ -43,7 +43,7 @@ angular.module('jamstash.player.directive', ['jamstash.player.service', 'jamstas
                     swfPath: 'bower_components/jplayer/dist/jplayer/jquery.jplayer.swf',
                     wmode: 'window',
                     solution: audioSolution,
-                    supplied: 'mp3, oga, m4a',
+                    supplied: 'mp3, oga, m4a, flac',
                     preload: 'auto',
                     errorAlerts: false,
                     warningAlerts: false,
@@ -119,6 +119,8 @@ angular.module('jamstash.player.directive', ['jamstash.player.service', 'jamstas
                         media= { m4a: newSong.url };
                     } else if (newSong.suffix === 'mp3') {
                         media= { mp3: newSong.url };
+                    } else if (newSong.suffix === 'flac') {
+                        media= { flac: newSong.url };
                     }
                     $player.jPlayer('setMedia', media);
                     if (globals.settings.Jukebox) {

However that wasn't enough to allow jPlayer to playback FLAC streams, so I researched this further and found out that the problem is that my browser (Chromium 46 on Debian stretch) doesn't report audio/x-flac as being supported through the canPlayType() API call. So I had to add one line to jPlayer to force the FLAC format as being supported, and voilà, FLAC streaming!

@Etuldan I did try this solution however the support in jPlayer is experimental and buggy. I couldn't get it to work although it's a really promising solution for the future!

Hyzual commented 9 years ago

I wonder if updating jPlayer would do the trick as we aren't using the latest version right now and it seems supported (from a quick look at their github). I'm a bit busy at this time but I can still integrate changes so please submit a pull request if you get it to work :). I might give it a try this weekend.

IvanVas commented 8 years ago

Same here. Flac playback isn't working. Tried both with transcoding on and off. Works on Android client.

jPlayer error:
Object {type: "e_no_support", context: "{supplied:'mp3, oga, m4a'}", message: "It is not possible to play any media format provid…dia() on this browser using your current options.", hint: "Video or audio formats defined in the supplied option are missing."} context: "{supplied:'mp3, oga, m4a'}"hint: "Video or audio formats defined in the supplied option are missing." message: "It is not possible to play any media format provided in setMedia() on this browser using your current options."type: "e_no_support"

Hyzual commented 8 years ago

I gave it a try today and I had the same results as @jcharaoui, jPlayer doesn't seem to play flac at all on Chrome. What is more worrying is that the last commit in jPlayer's repo is from last year, and judging from the pile of pull requests, it's not likely that this will be fixed anytime soon. I'll try to tinker a bit more with aurora.js which seems to be supported "experimentally" by jPlayer, maybe including it will let us play flac. If not, maybe we'll have to replace jPlayer with something else entirely.

jcharaoui commented 8 years ago

To be fair, according to my experiment, the fault doesn't seem to lie entirely with jPlayer. To determine which codecs are supported in the host browser, it uses a standard API, and part of the problem I've encountered is that my browser plays FLAC perfectly but the API reports it as unsupported. For exmaple, on this page, FLAC is displayed as not supported but the test works fine.

Koenvh1 commented 6 years ago

Any update on this? FLAC is now supported by both Firefox and Chrome (and the API returns this as well)