PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Mar 29, 2017 2:06 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Sep 22, 2016 9:04 pm 
Offline
Forum Contributor

Joined: Fri Jun 11, 2010 1:17 pm
Posts: 201
Hi everyone,
I am having a bit of difficulty making sure a sound (for new email notification for eg) is heard. It seems to work in google chrome, but not on mobile devices, ipad and it seems other programs on the computer could affect playback . this is what i have. what would you suggest? thanks.

I call this function after the page refreshes and a db query checks for any unread messages. Thanks for any assistance..

Syntax: [ Download ] [ Hide ]
<script type="text/javascript">function refreshPage(){setTimeout('window.location.href=window.location.href',60000);}</script>
<script language="javascript" type="text/javascript">
         function play_sound() {
                var audioElement = document.createElement('audio');
        audioElement.setAttribute('src', 'music/ding.mp3');
        audioElement.setAttribute('autoplay', 'autoplay');
        audioElement.load();
        audioElement.play();
    }
        function Delay_sound() {
                setTimeout("play_sound()", 45000);
        }
</script>
 


Top
 Profile  
 
PostPosted: Thu Sep 22, 2016 10:58 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13385
Location: New York, NY, US
iOS and some other mobile devices will not play audio/video in the browser unless initiated by a user click. Desktop browsers do not have this limitation. Only iOS apps can play audio not preceded by user input. Frustrating but that's Apple.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group