Recently, I've found that Google Music's new iOS specific web app (http://music.google.com) has the ability to "hijack" the native iOS iPod's music controls (double tap your home screen and use those pause, play, next, prev buttons while playing Go开发者_开发技巧ogle Music).
I had no idea that this was possible through a web app and have had trouble finding any examples or clues on how to achieve this through javascript. Does anyone have an idea?
iPhone is a WebKit browser therefore it supports the <audio>
tag. All you have to do is throw in an <audio>
tag with it's source linked to a playable audio format on WebKit (.aac for example) and you will have control over the audio file. You'll also notice an indicator in the top right of the screen to the right of your iPhone clock/time.
Here's all the info:
https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/AudioandVideoTagBasics/AudioandVideoTagBasics.html
Here's an example piece of code:
<!DOCTYPE html>
<html>
<head>
<title>Multi-Source Audio Player</title>
</head>
<body>
<audio controls autoplay >
<source src="http://Example.com/path/MyAudio.m4a">
<source src="http://Example.com/path/MyAudio.oga">
<source src="http://Example.com/path/MyAudio.wav">
</audio>
</body>
</html>
Here's iOS specific info:
https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW1
精彩评论