Autoplaying audio in a Webview (iOS)

This tutorial looks great tutorial - can’t wait to try it with a project.
Do you know how it will cope with audio in the hype document ?
When I have used Phone Gap in the past I’ve always got stuck on the audio.

I was wondering, with this method, is it possible to make apps with media auto trigger ? I know that user action is need d to play a sound when a Hype document is played within a browser on a mobile device, but is it still the case for an app built with your solution ?

Maybe someone else is better equipped to answer this, but you may need to set a 'NO' value for this property: UIWebView | Apple Developer Documentation

Yes and No
Yes you can get the audio to import as part of your Hype.html file into Xcode and it plays if you initiate the action to play sound. Clicking a button for example.
No extra OBJ C to write to make that happen.
For instance the attached Hype doc has the audio load as an On Scene Load action but since it is an HTML5 file ultimately Apple has a No auto load HTML video or audio policy.

What I am wondering is if…

  1. you created an element (a box) made it invisible.
  2. Have it move to another invisible element detect the collision and “play sound”

Yes that is a hack BUT it might just work it would appear as an auto play and could be integrated into a intro animation. Kind of like a hidden circuit in the app :wink:
If anyone else wants to have a go with it feel free and let me know. I will also try. (234.2 KB)



Long time ago, it was possible to send a MouseDown in MacroMedia Director. I whish we could do that in Hype.

So in opening a scene, such message would simulate an autoPlay and so play background sounds in iDevices.

Would’t that be great! If it was possible 20 years ago, why not now!


1 Like

SOLVED!! :smile:

I have spent some more time diving into this issue and I believe there is an answer albeit not an HTML5 answer.
Apple has blocked any HTML5 auto play for awhile on mobile iOS which we all know. The official reason is that they felt it would be a drain on the mobile carriers bandwidth if everyone could stream audio and video from web pages.

There is a way to override the autoplay ban but you need to adjust your Xcode file in order to do that.
You just need to add the line in your view controller.m file
self.Webview.mediaPlaybackRequiresUserAction = NO;

View the screenshot below to see where it is added in the .m file
I will add another How to Video on my channel to show Hype to Xcode with autoplay over the weekend.




Nick - audio in my app, embedded in hype, is working perfectly, but it plays as alert sound rather than system audio. In other words, if alerts are muted on the iPad or iPhone, you don’t hear it.

I’m not quite sure why this is - possibly the way I triggered it in hype with javascript linked to buttons or possible a setting in Xcode.

Do you have any thought on this ? As the app is mainly audio, I need to get it right before I think of submitting to Apple.


Replying to my own post here - Some apps play sound with the ringer off, some don’t.

When you bring a hype project in as a web view, it seems the ringer needs to be on to play audio.

In some Phone Gap apps I have seen, it works whichever way the ringer switch is set, however I don’t think this is a major issue.

1 Like

Yes one thing about XCode is everything is like a series of switches. You have to make sure all the right settings are applied one by one.
Are you still having trouble with it or has it been resolved?

The audio (from Hype) only plays when the ringer on the iPad is on - but that goes for other apps too, so I don’t think it is particularly an issue do you ?


Man, I just saw this so sorry…
Yes you have to have the ringer turned on. there might be a deeper way to override the switch but I have not stumbled on it yet.

Hi Nick - yes resolved. It’s working pretty well on the iPad, but I have yet to get the screen to resize properly for different devices. I’m hoping to get it on the app store but I know they are very fussy !


1 Like

They are and they are’nt just make sure you use the most recent conventions and all of your icon art is setup properly.
The adjustable size using Hype layouts has not translated for me yet.
I am trying some conversions with SWIFT so I’ll keep you posted.

Thanks Nick - I’ll let you know how I get on. The app currently has an external web link for uploading comments and pictures which they probably won’t like. I have used a Google font which I need to rasterise into the graphics, but on the plus side it is very simple !


1 Like

Hi Nick,

I can put a code directly with Hype to fix the problem without use Xcode?


Not sure I understand or are you asking if you can
create AutoPlay on an exported HTML5 file on an iOS device?

If that is the question I would say no.
Apple still has not allowed the use of AutoPlay for HTML5 based projects.
Mobile Safari has essentially disabled auto play and will not recognize it.

You have to put in a user “tap” touch event to launch it.

Hi Nick,

Here is my Xcode. I’m not sure how to enter it into my code. Can you assist? Thanks!