javascript - Use mp3 metadata or HTML to display artwork and track name on iPhone lock screen - Stack Overflow

When you lock an iphone after using safarichrome etc., when an mp3 file is playing, it displays blan

When you lock an iphone after using safari / chrome etc., when an mp3 file is playing, it displays blank artwork and a hard link to the mp3 file location, which looks quite ugly. Is there some alt tag/ meta data I can include to show artwork and the track title on this?

When you lock an iphone after using safari / chrome etc., when an mp3 file is playing, it displays blank artwork and a hard link to the mp3 file location, which looks quite ugly. Is there some alt tag/ meta data I can include to show artwork and the track title on this?

Share asked Oct 5, 2016 at 20:35 Michael WatsonMichael Watson 2444 silver badges11 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

You can add a string that will be shown on the iOS lockscreen by setting a title attribute on your <audio> element. It's all on the "song" line, so it doesn't look totally native, but it gets your point across.

I don't, however, know of any way to coax iOS into displaying album art of media ing from a browser.

If you want to display image on lock screen from your page you cannot do this, only iOS apps can. If you want to play music in background(while safari is closed, not killed) you can do it like this

var mp3 = document.createElement("audio");
   mp3.setAttribute('src', 'http://example./track.mp3');
   mp3.load();
   document.documentElement.appendChild(mp3);
   mp3.play();
   mp3.pause() // Pause

This is very similar to another post about showing the album thumnail on ios from safari where the solution suggested is to use the mediaSession api, that works pretty well for versions safari after 2021, using 512x512 image/jpg's, tested on ios 15.6 and 16.4

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742401960a4437089.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信