I try to do a notification system , that play a sound each time some one make a new post.
I am work in boostrap 4
I have chnge the way to do it by insert a javascript in the functions page but wen i call the javascript function give me all ways the same error of before
I go to post only part of all the code because is dimention
The sctipt i call is play_sound
and i call in an echo like this
echo '<script type="text/javascript">play_sound();</script>';
and i get same error then before
This is my error
Warning: Cannot modify header information - headers already sent by (output started at /home/nicetaxi/public_html/helpers/Functions.php:1) in /home/nicetaxi/public_html/helpers/Functions.php on line 208
This is the line of my error
function redirect_to_page($path = null)
{
header("location:" . SITE_ADDR . $path);
}
How can i solve this error
This is the functions page
<script type="text/javascript">
function play_sound() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'https://www.nicetaxi.eu/download/notifications.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.setAttribute('muted', 'muted');
audioElement.load();
audioElement.play();
}
</script>
<?php
My Answer:
Rate this post
4 of 5 based on 5992 votesComments