3

I have an audio element on a page which is currently being loaded inside an iframe with zero height and width. I'm using a postMessage from the parent page to tell the child page to play some audio.

This is working great on desktop browsers, however I'm having some trouble on mobile browsers. (I'm testing on Chrome for Android, but I think iOS will have the same problem).

Mobile browsers require that the media play() command is triggered by a user initiated action. In my case, the user is clicking a button on the parent page to initiate the play, but it seems that the when doing the postMessage, the browser looses track of that.

Is there any way for me to get audio to play inside the iframe without making the page inside the iframe visible to the user?

lucas
  • 1,910
  • 2
  • 21
  • 25
  • are you sure the problem is related to the _user initiated action_ limit? can you generally access the dom inside the iframe on the platforms where it is not working? – kr1 Feb 15 '13 at 08:09
  • I'm not trying to access the DOM inside the iframe directly. I'm using a postMessage to communicate between the parent page and the page in the iframe. – lucas Feb 15 '13 at 09:39

1 Answers1

0

You could try to directly access the inner DOM from the outside via myIframe.document. That way you can link your JavaScript objects and call a function upon click. That direct call may work better than posting a message. Limitations may apply according to this question: How can I access the contents of an iframe with JavaScript/jQuery?

Karsten
  • 2,772
  • 17
  • 22