如何使Safari播放本地音频资源?

时间:2019-11-23 04:30:39

标签: audio safari

这是macOS / Safari。

我可以通过在Safari中打开文件来播放此文件:https://learnwithecho.com/assets/test.m4a

但是,如果我将该文件保存在本地:

wget https://learnwithecho.com/assets/test.m4a

并启动Web服务器:

php -S 0.0.0.0:8888

并在本地加载相同文件:

open http://localhost:8888/test.m4a

然后我得到这个错误:

  

无法加载资源:插件处理的加载

如何在本地提供此文件,以便在Safari中正常播放?


这里是mediainfo的文件:

General
Complete name                            : assets/test.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (isom/iso2)
File size                                : 26.3 KiB
Duration                                 : 2 s 24 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 106 kb/s
Writing application                      : Lavf55.33.100

Audio
ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 2 s 24 ms
Duration_LastFrame                       : -20 ms
Bit rate mode                            : Constant
Bit rate                                 : 102 kb/s
Channel(s)                               : 1 channel
Channel layout                           : C
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 25.2 KiB (96%)
Default                                  : Yes
Alternate group                          : 1

1 个答案:

答案 0 :(得分:0)

好吧,这是我发现的最愚蠢的事情。

macOS / Safari(至少为13.0.3版)不支持使用相对URL在本地主机上播放媒体资源。

如果您使用诸如http://localhost ...这样的绝对URL,则将播放同一媒体。

这是未记录的Safari行为。

相关问题