Open Derekhk opened 9 years ago
Hi
Here is an adaptation of the code from this article, it will not work on all browsers. Paste it in the javascript editor in Silex
function playSound() {
try {
var url = "http://www.javascriptkit.com/script/script2/whistle.ogg"
var snd = new Audio(url);
snd.play()
} catch(e) {}
}
$(function() {
$('.sound-on-click').click(playSound);
$('.sound-on-hover').hover(playSound, function(){});
})
Then enter Silex "advanced" or "apollo" mode, and add the css class sound-on-click
to the elements on which your user will click to trigger the sound. Tell me if you do not know how to do this?
Also I added a "hover" so you can add the css class sound-on-hover
to elements, this will play the sound when the mouse goes over the element.
Edit: Another solution was proposed here in this issue by @BaguetteAgile
I am pretty new to web page building. I am building a page that will have several links or maybe speaker icons that the user can click on to play the sound associated with that link or icon. Hope that helps with what I am trying to do. Derek
I think that it will help do that But maybe a better way would be to put your sounds on SoundCloud.com and get the embed code (see this link for help on this http://help.soundcloud.com/customer/portal/articles/1209780-how-to-add-soundcloud-to-your-website)
Then you can paste the embed code in an html box in Silex. (create a new page and insert the html box then double click on it and then paste)
Web design is not hard but it takes time to learn
This second solution will display nice audio players in your Silex site
I like the idea of audio players. I have seen this on other sites and it is more appealing than links or icons. How hard is that to do? Sent from Yahoo Mail for iPhoneAt Jul 4, 2015, 3:15:36 PM, Alex Hoyau wrote:This second solution will display nice audio players in your Silex site
—Reply to this email directly or view it on GitHub.
Not hard at all Start with the random sound of SoundCloud to test. Follow the instructions and tell me if you manage to get the embed code
Good afternoon! I was wondering what part of the above code do i need to change to put a audio video from youtube in its place? I want it to automatically play once on page.
Hello You can copy the embed code of the video from youtube as explained here and paste it in an HTML box
Bonjour à tous, voici un code à coller dans une boite HTML pour avoir un lecteur de son sur votre site internet.
<audio controls preload="auto" src="ma-musique.mp3"> Votre navigateur ne supporte pas la balise audio . </audio> <font color="white"> Le nom de votre musique </font>
Nice! Thx @BaguetteAgile J'ai ajouté ta solution dans le widget
Is there a way to create a link on a webpage to play a sound?