http://jsfiddle.net/BC2VC/
I built an extremely simple audio player. Its just a .png in the background-image: of a <button> that uses .toggleClass() to change the background position of the .png showing a pause button.
I used javascript code that I found on a w3 reference which is a function that links the audio players play and pause events to the <button>.
I have three problems...
One, I cant figure out how to get one audio track to stop when the next when is clicked. I only want one track at a time to be able to play.
Two, if you click the play button for track one it switches to a pause button as it should, but then clicking on track two , both track one and two will show pause buttons. I need track one to switch back to a play button when any other play button is clicked, only one track at a time should show the pause symbol.
The third problem is: The code in the jsfiddle link above works to play the audio everywhere Ive tested except in jsfiddle.
here is a link to a page using the same exact code on my godaddy server...
http://liveoilfree.com/wtrclrwtrclr/index3.html
I'd recommend using one <audio> object and change it's source when user presses play on another song.
Use a javascript for-loop to reset all the play buttons except the active one.
Link that might help:
http://www.html5rocks.com/en/tutorials/webaudio/intro/
Related
Can it be done? I've been tryind to find some workarounds for a couple of hours now, like triggering a click event on an undisplayed button after the page loaded or using ngAfterViewChecked, I need to do this because I'm trying to create a game and I want the main menu to have some background music, obviously I'll add the options to mute it and turn up/down the volume later, but I'd really like it to start with it instead of having something that says "ehy click me to turn on the music" coz that would be quite stupid and ugly on the page, what's odd is that like 80% of the times when I re-compile the music starts, but when I reload the page not
Most browsers today require user interaction unfortunately, no way around it. The button could just say "click to start"
https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
I am trying to get the following:
Simple HTML website.
Custom button on it
When clicked, it should play a random audio file from a playlist
When clicked again, another random audio file from the playlist should start playing. and so on.
I already did it with one audio file by using this:
But i have no idea what to do to get it working with a playlist and and playing a random song from it.
Use some Javascript to create a random number, which needs to be between zero (or one depending on how you've got the audio arranged, as far as indexes). Link the JS to the button click.
I need to have several buttons where each button just determines what sound is to play when it is pressed, and one another play button that will play that determined sound. Is it possible in Flash AS3.
Anyone have an idea?
I'm trying to have a buttons show up to pick different options as a video is playing. Right now I have the buttons showing up when the page is loaded which means it sometimes trows the button sync out. How do I fix this? here is the link to my site. You have to wait until the video starts to play and you will see the buttons show up. But again it's timed with the page loading not with the video I'm trying to get it timed with the video.
http://preview.visiondesignstudio.net/WesternUniversity/Demo/
the simplest way would be to add an eventlistener to your video element based on timeupdated event. in the code that's called check the video's currentTime and compare that to the time(s) you want the button to be visible (eg you could have an array with elements listing buttonid, start-time and stop-time and show/hide the buttons as appropriate)
I have an youtube video playing in a specific frame. After researching a lot and not being able to properly destroy the player when exiting the frame, I decided to put a SoundMixer.stopAll() in all frames that can be used to get out from the youtube one. That makes things right in most of cases, because to access the video again I must click a button that reloads the player and everything gets back to the start. But I have some thumbs on the right side of the page that when clicked open a large image, occupying most of the page and not showing the video button, but they have a close button themselves. When I click the close button that movieclip becomes invisible and the one with the youtube video becomes visible again (what's great in all other cases). The point is: the player kept playing in the background and when I close the image you can see it playing again, but without sound. The only way to make the sound audible again is clicking on the seek bar (because it isn't a flash component itself, differently of the play/pause button) or going to another frame (that not one from the thumbs/images) and coming back. How could I make the sound play again automatically when entering the frame? Help to destroy the player when exiting the frame is also welcome.