How to play sound with ZeroClipboard? - javascript

Is there a way I can play a sound each time a click is made using ZeroClipboard?
I have a custom sound made that I want to play on those events.
PS. I can't use an <embed> here because I don't want the ugly "allow this page to play with quicktime" alerts that the browser will throw. Is there a way I can put in my sound in ZeroClipboard?

You have two options as i see it.
1. you can create a html5 audio player that plays a sound on the click event
2. you can create a flash file that houses a mp3 player. using flashvars you can send events to flash telling it to play the sound. the benefit of this is true cross browser compatibility (if your worried about this). this is essentially how the web experience of grooveshark and rdio operate. (mainly because of the html5 audio vulnerability)

Related

Allow Audio to Play on Page Load

I'm maintaining a legacy ASP/VBScript application for some warehouse scanners. They run Android 7 with Chrome 64. I can configure Chrome however I want so I'm not constrained like a normal website would be. Due to the nature of this web application, playing a sound on page load would improve usability (when the submitted action fails). Is there any way to allow an audio file to play on page load?
I can play sounds easily after a user interaction. However, I've tried multiple methods to play a sound on page load without success:
An <audio> tag with autoplay does not play (<audio autoplay="">).
Play the sound during the load event (Audio.play()). The returned Promise fails with the error:
NotAllowedError: play() can only be initiated by a user gesture.
Create an Audio with autoplay, and append it to body during the load event.
Create an Audio, append it to body, and .play() it during the load event. Yields the same "NotAllowedError".
Whitelisting the website for sounds in Chrome.
Ensuring the media autoplay setting is set to allowed in Chrome.
Both Chrome and Firefox, have dropped support for the autoplay attribute for both audio and video unless it's a video with the sound muted.
You can read more on that here: Autoplay Policy
However, recently I found a workaround using the Howler.js library, and it seems to work quite well in just these lines of code:
let timer, sound;
sound = new Howl({
src: ['<?= get_theme_file_uri() ?>/images/spotAudio.mp3']
});
sound.play();
You can download the library and read the docs here: https://howlerjs.com/

Change text inside html5 audio player - javascript

I am using cordova 3 and building app for ios.
I'm streaming audio channel using html5 audio player. Now as it has no stop function, so I had to change the source of the player to an invalid stream address to stop player both streaming and loading.
Before this stop mechanism, when I use the pause functionality the player kept loading the stream. That unacceptable. Because I don't want the user to waste bandwidth when the player is in pause mode. So the idea worked of that invalid addres. But when I set the address the player shows
cannot play audio file
I want to show
please select a channel
Is there any way to replace this text as I want to?? I tried
document.getElementById('myaudio').text="Plese select a channel";
It's not working. Player still shows cannot play audio file
How to achive this functionality?

Any Js which can detect flash video lenght and show play again and next video

I am wondering is there Java Script library or script or any trick which can detect flash video length and show play again and next video after its end.
As YouTube do.
any reference example or tutorial can also help me.
I am here after Google.
What you really want is the flash video player to make an ExternalInterface call to javascript letting it know it has completed. You would need access to the flash file to accomplish this.
You could technically track the video play progress with javascript and load the next video on complet. The problem with this is that it would require you not only to know the length of the video, but also when it plays/stop. The only way to do that is by having flash make ExternalInterface calls. At that point, you might as well just listen for the video's complete event.

Is there a way to detect when a Flash video has finished playing?

I work on a website that embeds videos from many different websites, the number of sources run into the thousands. For YouTube, their JavaScript API allows a way to detect when the video ends and one can execute any function he wants at that time. But this will only work for the youtube videos. What about all the others?
So is there a global all applicable way to detect when the Flash video on a page has stopped playing using either javascript or action script? And by "stopped playing" I mean stopped playing when it reached the end and not just been paused half way.
P.S. There will always be one embedded video inside a <div> with the id video on the page.
Just like YouTube provides an API, those players from those external websites have to provide their own APIs as well. There isn't an easy one-size-fits-all solution that you can implement in JavaScript.

Play sound in iPhone web app with Javascript?

I'm currently creating an iPhone web application for piano chords, and I wanted to add an option that would let the user press a Play button and play the selected chord. However, I'm not sure how to do this, or if it's even possible.
Basically, is there any way to programmatically (through Javascript) play a sound file (wav, mp3,...) in the background? (i.e. not leaving the page)
Thanks for any help!
(Keep in mind that I'm developing a web app, so I'm using HTML, CSS & JS, not the native SDK)
short answer: no
from the docs:
Safari on iPhone plays audio and video
in webpages in fullscreen playback
mode only.
yes you can.
http://www.schillmania.com/projects/soundmanager2/
see it in action at soundcloud.com
With HTML5 audio, iPhone can play without fullscreen.
IOS requires sound be played with the press of a control button. If you are looking to autoplay a sound at some event on an HTML page, forget it.

Categories