Print Page | Close Window

Audio Player Code

Printed From: openElement Website
Category:

openElement


Forum Name: Scripts for Your Website
Forum Description: Samples of scripts you can insert on your website using the element 'block of code.'
URL: https://forums.openelement.uk/en/forum_posts.asp?TID=902
Printed Date: Mar 29 2024 at 6:23am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Audio Player Code
Posted By: tlmac
Subject: Audio Player Code
Date Posted: Nov 27 2016 at 11:41pm
Hello,

Can some one tell me how to add audio player code to my site. I thought I was doing it correctly ( I chose the visual code block from the "Elements" tab), but the player does not appear when I preview it. Do I have to actually publish the page before seeing it?

Thanks,
tlmac


-------------
tlmac



Replies:
Posted By: Dmit OE
Date Posted: Nov 28 2016 at 9:12am
Hi,

It should work when you preview in a browser (F12)


Posted By: Dmit OE
Date Posted: Nov 28 2016 at 9:16am
If it does not, please publish your website somewhere and give the link


Posted By: skye
Date Posted: Feb 10 2017 at 6:47pm
Hello,

I have little problem with voice file's play:
Page1 has 2 text link with same href="../Voice.htm"

Page2 - this is Voice.htm - has a visual source code:
<audio autoplay>
  <source src="../Files/Audio/Sziv.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>
It works fine, however i want to change src="" on second page html with first page's text links.
Should it use php/javascript commands to send the wanted src attribute to second page's code ?
Thanks for every help!


-------------
Have you ever looked closely a dragon's eye ?


Posted By: Dmit OE
Date Posted: Feb 10 2017 at 8:07pm
You need either PHP or Javascript, no need for both. But be careful about security. If you send the URL via parameter and use it directly, anyone can abuse and inject harmful code, there are sevderal types of attack possible.
The easiest+safest is send only indexes / ids of links. So your links would be ../Voice.php?ind=1 and ../Voice.php?ind=2 (you may need to use LOCAL instead of HTTP + manually type at the bottom of link configuration).
On the link page (which you should make PHP using Page->Server Scripts), and in your Source Code Visual enter:

<?php
$name = "Sziv.ogg"; // default
if (isset($_GET['ind'])) {
  if ($_GET['ind'] == 1)
    $name = "Sziv.ogg";
  elseif ($_GET['ind'] == 2)
   $name = "Sziv2.ogg";
  elseif ($_GET['ind'] == 3)
   $name = "Sziv3.ogg";
  // and so on
}
?>
<audio autoplay>
  <source src="../Files/Audio/<?php echo $name ?>" type="audio/ogg">
  Your browser does not support the audio element.
</audio>



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net