开发者

Is there anyway to autoplay online content audio file on ipad

I want to play audio file on ipad which is located on some s开发者_开发问答erver. but thing is I want to autoplay audio file using HTML5. Please suggest me the way.

Thanks


The autoplay attribute is purposely disabled on iPhone and iPad:

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

Having said that there are some hacks for iOS 3 and iOS 4 to work around this with JavaScript. On iOS 3 you can create a link element and then simulate a click event to trigger the media element to play; on iOS4 you can simply call the load() and play() methods directly on the element.


Try this

NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString:@"www.example.com/play.mp3"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];

        [myWebView loadRequest: request];       
        [request release];

Hope this helps!!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜