| <!DOCTYPE html> |
| <html> |
| <head> |
| <script> |
| function go() { |
| var audio = document.getElementsByTagName('audio')[0]; |
| audio.play().then(playing).catch(notPlaying); |
| } |
| |
| function playing() { |
| try { |
| window.webkit.messageHandlers.testHandler.postMessage('playing'); |
| } catch(e) { |
| window.location = 'callback:playing'; |
| } |
| } |
| |
| function notPlaying() { |
| try { |
| window.webkit.messageHandlers.testHandler.postMessage('not playing'); |
| } catch(e) { } |
| } |
| </script> |
| </head> |
| <body onload="go()"> |
| <audio src="video-with-audio.mp4"></video> |
| </body> |
| </html> |