Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

How can we check if a person is using a iOS mobile Safari browser? #102

Open
mitchdowney opened this issue Jul 27, 2014 · 0 comments
Open
Labels

Comments

@mitchdowney
Copy link
Member

Currently there is a bug where when I play an audio clip on iOS, FIRST the audio player opens up and says "Cannot play file", THEN the player gets ready and can play.

I suspect this is happening because iOS Safari does not grab metadata (it sets the html5 audio preload to "none"), but I have this play() event triggered in the onloadedmetadata:

audio.onloadedmetadata = function() { 
    audio.play();
};

So I'm thinking that iOS is trying to call this .play() function as soon as I hit the play button, but since there is no metadata, it is reporting that it cannot play the file.

I am thinking if I 1) surround onloadedmetadata with an IF statement that checks if the user is using a Safari mobile browser, or 2) if I put an IF statement within onloadedmetadata around the audio.play(), that somehow checks whether there is any value loaded in the metadata attribute.

I imagine 2 would be a better solution, but I'm not sure it's possible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant