Reputation: 1211
I'm using PHP, i want to play sound file when new record added to database but i need to play that sound only once. i try below code with click function & it works
<?php
if(isset($_REQUEST["action"]))
if($_REQUEST["action"] == "play")
{
?>
<embed src="Kalimba.mp3" autostart="true" loop="false" style="width:5px; height:2px;">
<?php
}
?>
When click on play link it start that mp3 file
<a href="sound.php?action=play">Play</a>
Upvotes: 0
Views: 6260
Reputation: 11951
You cannot autoplay HTML audio on iPad (or any apple iDevice) without the user touching the screen first. That is built in their mobile webkit browser, to reduce network traffic. Check out this question to see a hacky way of doing it: Autoplay audio files on an iPad with HTML5
Upvotes: 0
Reputation: 29160
To play a sound on a website (pretty universally), you'll want to look into sound manager 2: http://www.schillmania.com/projects/soundmanager2/
If you are asking how to know when a new record is added to the database while the visitor is viewing a page (you want live checking and notification), you'll need to use ajax to fetch the highest id (or something to identify the newest record) and compare the unique identifier with javascript to the previous last id. If they do not match, a new record was added and you should trigger playing the sound.
Upvotes: 2