JavaScript sound library the doesn't require HTML 5 or Flash - javascript

Is there a reason that all of the audio javascript libraries I'm finding (jPlayer, SoundManager 2, etc.) try to use HTML 5, and if that doesn't work attempt to use Flash but then don't fall back to anything else? Why wouldn't they try to fall back to the default HTML sound tags like <embed>, <object>, or <bgsound>?
Is there a library out there that does? I'd like to be able to play a sound if the user is using IE6 without Flash installed.
Thanks!

You can have it fallback so that if the person doesn't support HTML5 and you want to use basic HTML then just download a sound file and let the browser run an application to play it.
It isn't ideal, but as was pointed out, before HTML5 you have very few options, and since you don't like Flash your options just got reduced.

Related

Can SoundManager2 use Flash as a backup for the same sounds if HTML5 is not available?

SoundManager2 seems awesome, but the main reason I'm looking to use something other than solo HTML5 is compatibility. What I would like SM2 to do is use HTML5 audio if available, and fall-back to Flash otherwise (for the same sounds). It seems like it should be able to do it, but I haven't yet figured out how.
For example, I'd create a sound called "moo" and link to the sound file. SM2 would then see if it can play that sound using HTML5. If not, it would load Flash to play the sound instead. From the perspective of my app, I should only request the playback of "moo" and SM2 would take care of making sure it plays.
I suspect it may be necessary for me to generate the audio clips in more than one format (possibly .ogg for HTML5 and MP3 for Flash?). I can do that if needed.
Alternatively, I could have my own JavaScript code to detect if the browser will be able to play sounds using HTML5 and pass a different configuration to SM2, but I'd prefer a cleaner way.
Thanks in advance :-)
yes, SM2 uses a Flash fallback:
Using HTML5 and Flash, SoundManager 2 provides reliable cross-platform
audio under a single JavaScript API
both SM2 and jPlayer will give you want you want, it just boils down to API preference.
generally, i'd choose jPlayer if cross-browser compatibility is crucial to you - SM2 is comparatively new to the world of HTML5 audio.. choose SM2 if you're happy using Flash and want more advanced features like access to the raw samples of the audio (to build a level meter or visualisation).
You should look into jPlayer.
It's what we use for cross-platform support. The documentation can be a little sparse at times, but it's rather useful.

Web AVI Player?

I'm looking to play AVI files in a web browser however I can't seem to find a decent tool to do so.
The basic WMP object embed is what I'm using right now but it doesn't really do what I'd like it to do, and I can't really implement JavaScript into it. (AFAIK I can't. I done a little digging and that's the conclusion I came to)
I've also tried DivX though I don't really like it. It has adverts, and I've no idea if JavaScript can be included either.
AFAIK Flash doesn't support AVI playback at all.
Does anyone know of any player at all that can play AVI files on the web, which I could possibly integrate some kind of JavaScript in (or has an API)?
Just a thought too, but would Java itself have anything like this?
The player also needs to be able to source the files like this:
file:\\Network-PC-Name\avi\avifile.avi
What you're looking for is WebChimera, there's no doubt about it. It has the most complex JS API ever made for web video, and it supports all file types.. it also supports "file:///" (for links like file:///C:/avi/avifile.avi).
It is open source and has no advertising. And the best part is that everything inside the player is editable, so you can skin it, add buttons and even add entirely new features to it with mostly just JavaScript. :)
Update
As you mentioned you need it to connect to file:///Network-PC-Name/avi/avifile.avi, this tells me you need this for some Local / Private / LAN use.
In this case, I think the best solution for you is to use WebChimera with Node-Webkit, as it will also give you a JS API based server environment.
WebChimera Player is already ported to NW for Windows and Mac:
https://github.com/jaruba/WebChimeraPlayerNW
On Windows, just download the package, and run nw.exe. To customize just edit the html pages. For Mac, just follow the instructions in the Readme.md.
The great part about using it like this, is that it already has the plugin embedded in the app, so you won't even need to install the plugin for the player to work.
The only thing I can't be fully sure of, is if Network-PC-Name can even be accessed through the file:/// protocol in it's normal usage. But this would still be possible anyway as you could map the network drive, and you can even map it programatically (with only JavaScript!) by using the child process exec to run the necessary command. (child_process is built in node-webkit natively)
flowplayer is recommended by this post:
Flash video player for AVI files (free for commercial use)
not sure about the file:\ source, as that's on your local machine and could be refused by the browser for security reasons

Javascript play sound

I want to know is there any play to play same wmv or mp3 from javascript, that will work for all the browsers?
I had a look at HTML5 audio tag, but seems i need to add there .ogg, .mp3,.wav files to support all the browsers, though i need to have only one audio file.
Any idea?
Many Thanks,
Hrayr
If you want the best cross-browser support, you should provide more than one encoding. It's very simple to generate the other versions using a free encoding tool like Audacity. Then, provide at least an mp3 and an ogg version of the resource (I wouldn't bother with wav) as this will cover all the browsers that support html5 audio. Then, if you want to provide a fallback option, like flash, you can cover all those users of non-html5 browsers who have the flash plug-in installed. You can use something like mediaelementjs to simplify the process of providing a unified player.
There probably is a way: http://jsmad.org/.
It is a pure javascript mp3 decoder.

Embedding Flash & Quicktime Via JavaScript

I have a JavaScript function that loads a flash movie into a webpage div using swfobject.embedSWF().
I want to be able to, alternatively, load a .mov file into the same div, in the event that this is the file found instead of the .swf.
Is there a close equivalent to swfobject.embedSWF for the purposes of embedding a .mov file? If not, what is an efficient route to doing this using JavaScript?
QTObject might do what you need and it's from the same author as SWFObject. It's old though, so I'm not sure if it will work well in modern browsers.
EDIT I searched and found reports of it working fine in IE7, Firefox 2 and Opera 9, so you might just be in luck. Just make sure you test it thoroughly.

HTML5 Local Storage of audio element source - is it possible?

I've been experimenting with the audio and local storage features of html5 of late and have run into something that has me stumped.
I'd like to be able to cache or store the source of the audio element locally to enable speedier and offline playback. The problem is I can't see how this is possible with the current implementation.
I have tried the following using WebKit:
Creating a manifest file to set up local caching but the audio file appears not to be a cacheable item maybe due to the way it is stream or something
I have also attempted to use javascript to put an audio object into local storage but the size of the mp3 makes this impossible due to memory issues (i think).
I have tried to use the data uri and base64 to use the html as a audio transport that can be cached but again the filesize makes this prohibitive. Also the audio element does not seem to like this in WebKit (works fine in mozilla)
I have tried several methods of putting the data into the local database store. Again suffering the same issues as the other cases.
I'd love to hear any other ideas anyone may have as to how I could achieve my goal of offline playback using caching/local storage in WebKit.
I've been trying to do this myself, on the iOS (for iPhone / iPad) but it refuses to cache audio files in offline, even if in Cache Manifest.
It does not error, but instead simply pretends to have played the audio element if invoked via JavaScript without a control. If it's embedded with a control, it displays an alternate control that says "Cannot play audio file.". It works fine if the application is able to go online.
It seems not to cache the audio, playing another sound resource seems to cause it to clear the previous resource from memory - this is pretty worthless functionality even when online.
I have experimented with base64 encoding the audio as data URI's. This works in Safari on the desktop (at least for fairly short samples of around 20-30k that I've been using) but seems not to be supported at all on iOS - it silently does nothing, which is highly annoying.
I don't know about other vendors - Google Chrome used to not support data URI's for audio but perhaps they fixed it... - it seems like it's not possible for now though.
Update: Minor discrepancy with iPhone OS 3.x (tested with 3.1.2): If an audio element is specified in an offline web app but it doesn't have a control, it displays a non-interactive control with a non-animated spinner on it (which it definitely shouldn't do). I assume this is fixed in iOS 4.x (which should be out next week).
So it's been a while since I asked this question and I thought i'd give some info about how we solved it. Basically we encoded the data into PNG's using a similar technique to this:
http://audioscene.org/scene-files/yury/pngencoding/sample.html
Then cached the image on the mobile device using html5 local storage and accessed it as needed. The PNG's were pretty big but this worked for us.
I spent a while trying to do this for a game I'm making, and since as far as I could tell browsers (Firefox and Chrome) still don't support caching of audio elements I thought I'd post the solution I found.
There is a workaround described here: http://dougx.net/plunder/index.php#code
I can confirm it works pretty well, but is probably better suited to smaller files. As he describes here (http://dougx.net/plunder/GameSounds.txt), you encode the audio as base64 strings, and give them a data:audio/ogg;base64 (or any compatible audio format) header, which HTML5 audio can then read in. Because this is just a string, the browser will cache it.
I guess it would be preferable to get the manifest approach working, since this feels like the most relevant mechanism for locally caching the file.
What happens if you alter the audio file's HTTP headers, e.g. Content-Type and Expires? Does the browser do something different if the file extension is changed?
I see you've had no luck so far.
You might want to take a look at JAI (JavaScript Audio Interface) ("the world's first javascript interface for web <audio>"). Or get in touch with Alastair MacDonald, who wrote it.
Failing that, the HTML5 Doctor may be able to assist.
Adding video and audio files to local storage works with iOS 4.3.
I just added a video and an audio file to manifest and they both got downloaded to offline storage on iPad.

Categories