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

No audio in Safari (macOS and iOS) #105

Closed
willcassella opened this issue Nov 13, 2020 · 37 comments
Closed

No audio in Safari (macOS and iOS) #105

willcassella opened this issue Nov 13, 2020 · 37 comments

Comments

@willcassella
Copy link

I've noticed this in my own instance as well as the demo instance. Attempting to play any track will change the 'play' button to a 'pause' button, but there is no audio and the progress bar does not move.

@epoupon
Copy link
Owner

epoupon commented Nov 13, 2020

Hi!
Unfortunately I don't have such devices to test. Maybe you can gather some useful information from the browser debug panel or from the server?
Have you tried to play with the transcoding settings (auto, force on, force off, output format) ?

@willcassella
Copy link
Author

No errors appear in the debug panel, but changing the transcode format to 'mp3' fixes the issue (for both macOS and iOS). No other format seems to work, however I think we can blame that on Safari.

@epoupon
Copy link
Owner

epoupon commented Nov 14, 2020

Hmm this is strange.
By default the player tries to read the native file, and fallbacks on a transcoded stream. As the native file of the demo instance are mp3 files, it should just work?

@willcassella
Copy link
Author

Testing in macOS Safari, attempting to play 'Golden Hour' from the album 'Petal' (on the demo site) refuses to play with the default transcode settings:

  • Enable Transcoding = Only when format is not supported
  • Transcode Format = Ogg/Opus

I can't adjust the settings on the demo site so I don't know what would make them work.

On my own instance, playing an mp3 with 'Enable Transcoding' set to 'Never' refuses to play, but with it set to 'Only when format is not supported' and 'Transcode Format' set to 'mp3', it enables transcoding and plays successfully. Dragging the source mp3 onto a new tab in Safari plays it just fine, so I'm not really sure what's going on.

@epoupon
Copy link
Owner

epoupon commented Nov 16, 2020

Ok thanks for your investigation, it looks like there is something that is not well handled in LMS's player with native files

@b4too
Copy link

b4too commented Sep 19, 2021

I tested on an ipad and an iphone and I confirm, transcode format mp3 does the trick indeed.
Could we maybe force this particular setting to all requests being proxied with the keyword AppleWebKit ?
On my reverse proxy it is how I identify all Apple devices.

@epoupon
Copy link
Owner

epoupon commented Sep 26, 2021

Did you notice any useful error in the logs on your apple devices (not sure it is easy to get though)?

@b4too
Copy link

b4too commented Sep 29, 2021

Maybe this error that comes up often ? ( server side only, I do not have an apple computer so no log examination for me unfortunately )
[2021-Sep-29 16:48:01.763] 1 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
I did notice also that even with the transcode option mp3, after some time ( for a 3mn music it could be at 2mn ) the song will restart from the beginning though visually the progress bar still goes on as if it wasn't reset. It will then loop indefinitely, I observed it on an iphone and on an ipad, both on firefox and safari.

@epoupon
Copy link
Owner

epoupon commented Sep 29, 2021

Do you have a reverse proxy that may timeout the connection? Do you reproduce when you connect directly without the reverse proxy?

@b4too
Copy link

b4too commented Oct 4, 2021

With or without the proxy the issue stays the same, I made a little capture for you to see.
At 00:55 you can see the playback suddenly stops, server side I have another error like this :
[2021-Sep-29 16:48:01.763] 1 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
Then I start again the song but this time with the repeat, and now from 3:13 to the end you will see the loop I was talking about.

@HubKing
Copy link

HubKing commented Sep 6, 2022

Well, I attest that the latest iPadOS Safari cannot play music from the web interface. How about referring to the NPR's streaming code? I am not a web programmer, so I don't know how it works, but it seems to be the best player example for iPad Safari.

If you visit https://www.npr.org, there is an "On Air Now" play button at the top-right corner. iPad Safari could play that audio stream and moreover, the stream did not stop when I turned off the screen. Whatever NPR is using, this is better than those web player interfaces of other streaming servers, because those players were stopped when turning off the screen.

@epoupon
Copy link
Owner

epoupon commented Sep 6, 2022

Thanks for testing @HubKing. I guess you can't access any valuable error log on the client?

@epoupon
Copy link
Owner

epoupon commented Sep 6, 2022

And more important, is it also the case with the epoupon/lms:915e114 image?

@HubKing
Copy link

HubKing commented Sep 6, 2022

Nah, Safari on iPad still can't play music with that Docker image. I don't know how to access debug output of iPad Safari. If the same problem happens on mac Safari, it probably easier to get debug output of mac Safari. Anyway, here is the server's log when I tried to play an MP3 song in iPad Safari.

Attaching to lms
lms  | ARG = /usr/bin/lms
lms  | ARG = --config=/var/lms/wt_config.xml
lms  | ARG = --docroot=/usr/share/lms/docroot/;/resources,/css,/images,/js,/favicon.ico
lms  | ARG = --approot=/usr/share/lms/approot
lms  | ARG = --deploy-path=/
lms  | ARG = --resources-dir=/usr/share/Wt/resources
lms  | ARG = --http-port=5082
lms  | ARG = --http-address=0.0.0.0
lms  | ARG = --threads=8
lms  | [2022-Sep-06 22:25:44.475] 1 - [info] "config: reading Wt config file: /var/lms/wt_config.xml (location = '/usr/bin/lms')"
lms  | [2022-Sep-06 22:25:44.475] 1 - [info] - [UTILS] Starting IO context with 8 threads...
lms  | [2022-Sep-06 22:25:44.475] 1 - [info] - [DB] Creating connection pool on file /var/lms/lms.db
lms  | [2022-Sep-06 22:25:44.489] 1 - [error] - [DB] Cannot create tables: Sqlite3: create table "cluster_type" (
lms  |   "id" integer primary key autoincrement,
lms  |   "version" integer not null,
lms  |   "name" text not null,
lms  |   "scan_settings_id" bigint,
lms  |   constraint "fk_cluster_type_scan_settings" foreign key ("scan_settings_id") references "scan_settings" ("id") on delete cascade deferrable initially deferred
lms  | ): table "cluster_type" already exists
lms  | [2022-Sep-06 22:25:44.489] 1 - [info] - [DB] Database version = 37, LMS binary version = 37
lms  | [2022-Sep-06 22:25:44.496] 1 - [info] - [COVER] JPEG export quality = 75
lms  | [2022-Sep-06 22:25:44.496] 1 - [info] - [COVER] Default cover path = '/usr/share/lms/approot//images/unknown-cover.jpg'
lms  | [2022-Sep-06 22:25:44.496] 1 - [info] - [COVER] Max cache size = 30000000
lms  | [2022-Sep-06 22:25:44.496] 1 - [info] - [COVER] Max file size = 10000000
lms  | [2022-Sep-06 22:25:44.496] 1 - [info] - [COVER] Preferred file names: cover,front
lms  | [2022-Sep-06 22:25:44.511] 1 - [info] - [METADATA] Creating TagLib parser with read style = accurate
lms  | [2022-Sep-06 22:25:44.511] 1 - [info] - [DB UPDATER] skipDuplicateRecordingMBID = 0
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [DB UPDATER] Using scan settings version 1
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [SCROBBLING] Starting service...
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [RECOMMENDATION] Reloading recommendation engines...
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [SCROBBLING] [listenbrainz] - Starting Listens synchronizer, maxSyncListenCount = 1000, _syncListensPeriod = 1 hours
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [SCROBBLING] [listenbrainz] - Starting Feedbacks synchronizer, maxSyncFeedbackCount = 1000, _syncFeedbacksPeriod = 1 hours
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [SCROBBLING] [listenbrainz] - Starting ListenBrainz scrobbler... API endpoint = 'https://api.listenbrainz.org'
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [SCROBBLING] Service started!
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] - [MAIN] Starting server...
lms  | [2022-Sep-06 22:25:44.512] 1 - [info] "WServer/wthttp: initializing built-in wthttpd"
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [RECOMMENDATION] Initializing engine 'clusters'...
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [RECOMMENDATION] Initializing engine 'clusters': complete
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [RECOMMENDATION] Recommendation engines loaded!
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [DB UPDATER] Scheduling next scan
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [DB UPDATER] Using scan settings version 1
lms  | [2022-Sep-06 22:25:44.513] 1 - [info] - [DB UPDATER] Auto scan disabled!
lms  | [2022-Sep-06 22:25:44.515] 1 - [info] "wthttp: started server: http://0.0.0.0:5082"
lms  | [2022-Sep-06 22:25:44.515] 1 - [info] - [MAIN] Now running...
lms  | [2022-Sep-06 22:25:53.963] 1 - [info] "Wt: session created (#sessions = 1)"
lms  | [2022-Sep-06 22:25:53.963] 1 [/ nYXN2KISHQ2GLRhI] [info] "WEnvironment: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15"
lms  | [2022-Sep-06 22:25:53.963] 1 [/ nYXN2KISHQ2GLRhI] [info] "Wt: signal from dead session, sending reload."
lms  | [2022-Sep-06 22:25:53.963] 1 - [info] "WebController: Removing session nYXN2KISHQ2GLRhI"
lms  | [2022-Sep-06 22:25:53.963] 1 [/ nYXN2KISHQ2GLRhI] [info] "Wt: session destroyed (#sessions = 0)"
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:53.964] "POST /?wtd=HAntcZCpPbJhDWKc HTTP/1.1" 200 76
lms  | [2022-Sep-06 22:25:54.450] 1 - [info] "Wt: session created (#sessions = 1)"
lms  | [2022-Sep-06 22:25:54.450] 1 [/ nrB8gPIOn3WCwdmB] [info] "WEnvironment: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15"
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:54.451] "GET /release/1 HTTP/1.1" 200 2359
lms  | [2022-Sep-06 22:25:54.978] 1 [/ nrB8gPIOn3WCwdmB] [warning] "WApplication: WApplication::addMetaHeader() with no effect"
lms  | [2022-Sep-06 22:25:54.991] 1 [/ nrB8gPIOn3WCwdmB] [info] - [UI] User 'test' logged in from '172.21.0.1', user agent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:54.999] "GET /?wtd=nrB8gPIOn3WCwdmB&request=style&page=1 HTTP/1.1" 200 114
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.006] "GET /?wtd=nrB8gPIOn3WCwdmB&sid=1136279323&webGL=true&scrW=1024&scrH=1366&tz=540&tzS=Asia%2FTokyo&htmlHistory=true&deployPath=%2F&request=script&rand=2342578998 HTTP/1.1" 200 42030
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.010] "GET /css/lms.css HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.019] "GET /css/bootstrap.solar.min.css HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.020] "GET /resources/webkit-transitions.css HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.022] "GET /resources/font-awesome/css/font-awesome.min.css HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.047] "GET /js/bootstrap.bundle.min.js HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.065] "GET /js/mediaplayer.js HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.088] "POST /?wtd=nrB8gPIOn3WCwdmB HTTP/1.1" 200 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.230] "GET /resources/font-awesome/fonts/fontawesome-webfont.woff2?v=4.3.0 HTTP/1.1" 304 0
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.239] "GET /?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fg&ver=1&releaseid=1&size=512 HTTP/1.1" 200 18788
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.260] "POST /?wtd=nrB8gPIOn3WCwdmB HTTP/1.1" 200 627
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.501] "GET /release/?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fn&ver=1&trackid=4 HTTP/1.1" 206 2
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.501] "POST /?wtd=nrB8gPIOn3WCwdmB HTTP/1.1" 200 3540
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.537] "GET /?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fg&ver=1&releaseid=2&size=128 HTTP/1.1" 200 2482
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.538] "GET /?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fg&ver=1&releaseid=2&size=512 HTTP/1.1" 200 15507
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.540] "GET /?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fg&ver=1&releaseid=1&size=128 HTTP/1.1" 200 2812
lms  | 172.21.0.1 - - [2022-Sep-06 22:25:55.570] "GET /release/?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fn&ver=1&trackid=4 HTTP/1.1" 206 5289384
lms  | [2022-Sep-06 22:25:56.024] 1 [/ nrB8gPIOn3WCwdmB] [info] - [TRANSCODE] [0] - Transcoding file '/music/file_example_MP3_5MG.mp3'
lms  | [2022-Sep-06 22:25:56.235] 1 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
lms  | 172.21.0.1 - - [2022-Sep-06 22:26:04.944] "GET /release/?wtd=nrB8gPIOn3WCwdmB&request=resource&resource=on7g3fg&ver=1&trackid=4&size=128 HTTP/1.1" 200 2482
lms  | 172.21.0.1 - - [2022-Sep-06 22:26:45.551] "POST /?wtd=nrB8gPIOn3WCwdmB HTTP/1.1" 200 0

@sommerper
Copy link

Just had the same issue. I fixed it by setting encode to "always" and "mp3" in settings. Then both Safari and iOS browsers will work.

@epoupon
Copy link
Owner

epoupon commented Oct 28, 2022

Thanks for reporting this.
Is this needed even for mp3 files? I mean is forcing transcode to the same format a workaround?

@sommerper
Copy link

Yep. I only have mp3 files and had to do it anyway.

@epoupon
Copy link
Owner

epoupon commented Oct 29, 2022

Ok, and if you set to transcode only if needed to mp3, does it work ?

@sommerper
Copy link

No, that was the default and it does not work. It has to be set to always.

@epoupon
Copy link
Owner

epoupon commented Oct 30, 2022

Ok, would you accept to test a change? If yes, which lms version are you using (arch, docker)?

@sommerper
Copy link

Sure. I'm using the docker version.

@epoupon
Copy link
Owner

epoupon commented Oct 30, 2022

Amd64?

@sommerper
Copy link

I’ve been using docker version on arm (pi4) but I can also test on my intel machine. It will just take a little longer because of some network settings.

@epoupon
Copy link
Owner

epoupon commented Oct 30, 2022

Ok and last question: 32 or 64bits?

@epoupon
Copy link
Owner

epoupon commented Oct 30, 2022

And another last question: what if you set to never transcode?

@sommerper
Copy link

sommerper commented Oct 30, 2022

64bits for both arm and intel.

never transcode does not work. It has to be on always and mp3

@obiwantoby
Copy link

obiwantoby commented Feb 10, 2023

I'm looking at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio

Loading a pure form .mp3 works fine, the exact sample works fine in Safari.

<figure>
    <figcaption>Listen to the T-Rex:</figcaption>
    <audio
        controls
        src="/media/cc0-audio/t-rex-roar.mp3">
            <a href="/media/cc0-audio/t-rex-roar.mp3">
                Download audio
            </a>
    </audio>
</figure>

Substituting what is being provided from LMS fails.

<html>

<figure>
    <figcaption>Listen to the T-Rex:</figcaption>
    <audio
        controls
        src="http://192.168.50.3:5082/release/?wtd=IFo8nVj1vpJcrs0f&request=resource&resource=o1litfg&ver=1&trackid=2885">
            <a href=".?wtd=IFo8nVj1vpJcrs0f&amp;request=resource&amp;resource=o1litff&amp;ver=1&amp;trackid=2885&amp;bitrate=320000&amp;format=2">
                Download audio
            </a>
    </audio>
</figure>

</html>

But that works in Firefox. However, looking at the spec if you specify the codec, it works fine in Safari.

<html>

<figure>
    <figcaption>Listen to the T-Rex:</figcaption>
    <audio controls>
        <source src="http://192.168.50.3:5082/release/?wtd=IFo8nVj1vpJcrs0f&request=resource&resource=o1litfg&ver=1&trackid=2885" type="audio/mpeg" />
    </audio>
</figure>

</html>

I am not quite sure how this is formed in the code yet, but will try to branch it and test it. I am not quite sure how you determine if transcoding needs to occur or not.

For reference how LMS will format the audio tags.

Screenshot 2023-02-09 at 11 00 56 PM

This example works. I suspect rather than a dynamic tagging system, targeting both mpeg and ogg. Seems reasonable to edit the template.

https://thepaciellogroup.github.io/AT-browser-tests/test-files/audio.html

https://github.com/epoupon/lms/blob/6898a4096a7d4f999f08102f26b92d48a64d75e1/approot/mediaplayer.xml

@obiwantoby
Copy link

obiwantoby commented Feb 10, 2023

I have forked this and am trying some changes. I think it is reasonable to use a conditional here. Otherwise need to define the relationship between transcode or not, still not sure how that is triggered, how does it know to transcode?

/workspaces/lms/docroot/js/mediaplayer.js

Kinda hate JS, but using some references ... we should prefer the higher quality ogg vorbis format first. Issue here still is if transcoding is set to something other than what the browser supports. Probably need to rethink the tagging and transcoding relationship - in the same file.

http://diveintohtml5.info/everything.html

	let acodec = document.createElement('audio');
		if (!!(acodec.canPlayType && acodec.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''))) {
			source.type= 'audio/ogg';
		} else {
			source.type= 'audio/mpeg';
		}

Will see if I can test it and do a pull request.

The other logical solution ... exotic.

https://stackoverflow.com/a/41706900

@epoupon
Copy link
Owner

epoupon commented Feb 11, 2023

Thanks for investigating this!

For the record:

  • if you select transcode "only when format is not supported", LMS exposes two audio sources and expect the browser to fallback if necessary to the second one if the first one is not supported:
    • a first audio source that points to the "raw" file resource
    • a second audio source that points to the transcoded file resource
  • if you select transcode "never", only the "raw" file resource is exposed
  • if you select "always", only the transcoded file resource is exposed.

The transcoded file resource sets the mimetype in its response, so thanks to your investigations I think this is why it works.
The raw file resource does not provide it, and indeed it looks like this makes Safari unhappy (not sure why it does not try to fallback to the second source though)
So I guess all we have to do is to set the proper mimetype for the "raw" resource. Will try this asap.

@epoupon
Copy link
Owner

epoupon commented Feb 11, 2023

@obiwantoby could you by chance test the epoupon/lms:bf0f8b7 docker image?

@obiwantoby
Copy link

Yeah, I can switch around from the one I compiled, will report back.

@epoupon
Copy link
Owner

epoupon commented Feb 11, 2023

Thanks! you can also just apply bf0f8b7 if it is easier for you

@obiwantoby
Copy link

Safari desktop seems fine. Safari iOS is better but is failing on some FLAC collections, that otherwise worked. Trying to play around with it more.

@obiwantoby
Copy link

Confirmed epoupon/lms:bf0f8b7 fails on iOS.

@epoupon
Copy link
Owner

epoupon commented Feb 22, 2023

Confirmed epoupon/lms:bf0f8b7 fails on iOS.

Does it fail for all files or just for flac files?

@obiwantoby
Copy link

Well no, other files, of which I only have MP3 and some AAC are fine. FLAC fails, but only on iOS. where as before everything would play.

@epoupon
Copy link
Owner

epoupon commented Feb 23, 2023

Ok thanks for testing! Will merge this first fix then, since it is better than before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants