I want to create an audio file to play in iphone safari browser but without the help of HTML page. Just in Pure javascript or Jquery. Thanks in advance.
Asked
Active
Viewed 2,797 times
0
-
Have you tried [Google](https://www.google.com/search?q=jquery+audio)? – DACrosby Sep 12 '12 at 20:05
-
Javascript/jQuery is made to manipulate something else, HTML most of the time. Javascript in itself can't create the needed connections to play an audiofile. And since you are running it the browser, you need something to execute the Javascript, namely HTML. – Henrik Ammer Sep 12 '12 at 21:06
-
The answer here will help you and please use google. http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent – KyelJmD Sep 15 '12 at 06:31
1 Answers
3
var audio = new Audio();
audio.id = "mySong";
audio.src = "//mysite.com/media/mysong.mp3";
Except that you can't autoplay the song in audio. You can't autoload a song on an i___ device. ...so you need to custom-build controls, which you then have to put on an HTML page, with event listeners to listen for clicks or taps, in order to play/pause the song, or change tracks or whatever...
So you still need an HTML page.
Moreover, this will ONLY work in the browser, as there's no other way to get this to function outside of a browser, on an iPhone (not 100% true, but Audio
is an HTML5 API, ergo, HTML5 support is required to use that particular API).

Norguard
- 26,167
- 5
- 41
- 49