Giter VIP home page Giter VIP logo

createjs / soundjs Goto Github PK

View Code? Open in Web Editor NEW
4.4K 4.4K 839.0 82.25 MB

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.

Home Page: http://createjs.com/

License: MIT License

CSS 1.48% JavaScript 84.94% ActionScript 1.56% HTML 3.79% SCSS 5.54% Handlebars 2.68%

soundjs's Introduction

2.0 BETA

This repo is in beta. Reporting issues is appreciated.

createjs

This package compiles the combined bundles for CDN distribution. It is mostly for internal use.

Usage

Install dependencies prior to compiling builds.

npm install

It's recommended that you use npm link to compile from local packages.

npm run build -- [--production] [--format=global,module,common]
  • combined builds with flag control for custom output
npm run build-prod
  • combined build restricted to minified global format for the CDN

soundjs's People

Contributors

bdero avatar benwick avatar danzen avatar gskinner avatar gskinner-blair avatar konistehrad avatar lannymcnie avatar mannyc avatar naranjamecanica avatar nuclearcookie avatar santhoshvasabhaktula avatar seanfeld avatar timgates42 avatar vaenow avatar wdamien avatar yar3333 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soundjs's Issues

getPosition returns 0 for first ~200ms

Issue :

Calls to getPosition on a playing SoundInstance return 0 during the first 200ms or so, despite the sound playing correctly during that period.

Platform : Google Chrome 21.0.1150.0 canary on Windows 7 SP1

Repro :

Given the following HTML.

<html>
  <head>
    <title>
        REPRO
    </title>
  </head>
  <body>
    <script src="http://code.createjs.com/preloadjs-0.1.0.min.js"></script>
    <script src="http://code.createjs.com/soundjs-0.2.0.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">

$(document).ready( function() 
{
  var audioFile = { src: 'http://www.tons-of-slack.net/soundjs/audio.mp3', type : PreloadJS.SOUND, id : 'somesound' };

  preload = new PreloadJS();
  preload.installPlugin(SoundJS);
  preload.onComplete = function() 
  {
    var sound = SoundJS.play('somesound');
    var intervalId = setInterval( function() { console.log(sound.getPosition());  }, 20 );
    sound.onComplete = function() { clearInterval(intervalId); }
  }
  preload.loadFile(audioFile);
});
    </script>
  </body>
</html>

The console output receives several dozen times '0', followed by a correct-looking sequence starting around 200.

Expected : the output sequence should not have a gap of only 0 between 0 and ~200.

Problems with IE9 in HTMLAudioPlugin and FlashPlugin

Applies to v3 and NEXT (v4b) in IE9 (haven't tested IE10).

Some sounds play intermittently in HTMLAudioPlugin, while some sounds start playing and then cut out before they are complete.

Sound volume adjustments do not work in the FlashPlugin.

Mute does not work for sounds that are played after setMute is called in either HTMLAudioPlugin or FlashPlugin.

SoundJS.play always returns null

Issue : the play static method of SoundJS returns null when loading a sound file

Platform : Google Chrome 21.0.1150.0 canary on Windows 7 SP1

Repro :

<html>
  <head>
    <title>
        REPRO
    </title>
  </head>
  <body>
    <script src="http://code.createjs.com/soundjs-0.2.0.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">

$(document).ready( function() 
{
  var sound = SoundJS.play('http://www.tons-of-slack.net/soundjs/audio.mp3');
  console.log( sound );
});
    </script>
  </body>
</html>

Result : console output is null

Expected : The sound variable should be a SoundInstance object

Music Visualiser( sample file ) not working in Chrome

I tried running the MusicVisualizer.html, example file, on Chrome Version 24.0.1312.57 m on Windows XP

But gave me an error shown below

Sorry!
SoundJS or Web Audio is not currently supported in your browser. Currently only Chrome and iOS6 Safari support web audio.

Another one: I tried running game.html in iPad 2 on a Chrome browser ver 21.0

Got Error shown below..
Sorry!
Mobile devices require sound to be played inside user events, which this demo does not.

To fix this, I commented the auto playing sound and put it within the handleClick() function. So that it fires on user interaction.. but still the same issue..

--Ram

Rename tag v0.1.0 to be compatible with current format

Because of different version formatting, I am not able to install SoundJS via Bower. Bower is always trying to install the newest tag, which is by alphabetical order v0.1.0.

You should change "v0.1.0" to "release_v0.1.0" this way:

git tag release_v0.1.0 v0.1.0 # creates new tag
git tag -d v0.1.0 # deletes old tag
git push origin :refs/tags/v0.1.0 # deletes old tag from remote repo

ID handling could be more flexible in TestAudioStall

From line 1140-1144 of sound.js:

var parts = target.id.split("_");

if(SoundJS.soundHash[parts[0]][parts[1]].loaded){
  return;
}

The above code breaks if the target's ID is something like "beep_long_1" because you end up splitting on underscores and thus not having the appropriate key to look up in SoundJS.soundHash. (SoundJS also uses underscores to differentiate sound instances, which may or may not be the most durable way to do that.) I considered patching, but since you're planning a big overhaul, this code might not even exist in your edge version anymore, so this is more of an FYI.

SoundChannel.getSlot() seems to be failing on playState='playFinished'

Hey,

it seems as the SoundChannel.getSlot() method seems to be failing if a sound instance has finished playing.

These finished instances can't be reused if interruption flag was set to none.
I think this doesn't make sense to have it that way, because finished sound instances should be reusable, right?

I marked the line in the code "quote" below, where it skips the rest of the code. So the circumstance of having a finished sound instance will fail, because the relevant check for it is below the check against interruption.

Is this behaviour correct or wanted?

~Cheers, Chris

        getSlot: function(interrupt, instance) {

// ... more code

            for (var i=0, l=this.max||100; i<l; i++) {
                target = this.get(i);

                // Available Space
                if (target == null) {
                    return true;
                } else if (interrupt == SoundJS.INTERRUPT_NONE) {
// >>>> This seems to be false
                    continue;
                }

// ...more code

                // Audio is complete or not playing
                if (target.playState == SoundJS.PLAY_FINISHED ||
                        target == SoundJS.PLAY_INTERRUPTED ||
                        target == SoundJS.PLAY_FAILED) {
                    replacement = target;

                // Audio is a better candidate than the current target, according to playhead
                } else if (
                        (interrupt == SoundJS.INTERRUPT_EARLY && target.getPosition() < replacement.getPosition()) ||
                        (interrupt == SoundJS.INTERRUPT_LATE && target.getPosition() > replacement.getPosition())) {
                    replacement = target;
                }
            }

// ... more code

        }

SoundGrid example and documentation

I'm currently creating Haxe externs for CreateJs by parsing the data.json file generated by the YUIDoc tool and generally this has worked really well with the CreateJs libs because of the documentation provided. I'm currently looking at the SoundGrid example to check the generated SoundJs and PreloadJs externs and am having a few problems. I've listed them here:

SoundJs doesn't have a static property called 'FlashPlugin'
https://github.com/CreateJS/SoundJS/blob/master/examples/SoundGrid.html#L24

checkPlugin() is documented as being private and is missing @method and @param details
https://github.com/CreateJS/SoundJS/blob/master/src/soundjs/SoundJS.js#L432

The PreloadJs constructor comment is written as @param Boolean useXHR2 but should be like @param {Boolean} useXHR2.
This is also an optional param based on the SoundGrid example. Is there a standard way of indicating that a param is optional with YUIDoc?
https://github.com/CreateJS/PreloadJS/blob/master/src/preloadjs/PreloadJS.js#L38

onLoad and onComplete are not documented.

Another related question -

I see that you use the following way to document when a method is overloaded:
@return {String | Number | Boolean} The capability value
(https://github.com/CreateJS/SoundJS/blob/master/src/soundjs/SoundJS.js#L275)
Is this a YUIDoc convention or your own convention?

cheers,

Fintan

SoundJS not setting up properly on Firefox?

I'm using the following version of CreateJS: http://code.createjs.com/createjs-2013.02.12.min.js

My code runs fine on every browser, except Firefox. For some reason, if I upload the files to the server and run from there I get a "TypeError: g is null". If I run locally it works. Again, I don't have this problem on other browsers, even when the files are on the server.

Trying to find a solution to my problem I realized createjs.Sound.activePlugin is a [WebAudioPlugin] and its capabilities are null (that is the g above) whenever I'm accessing the files from the server.

My code is basically this:

var queue = new createjs.LoadQueue();
queue.installPlugin(createjs.Sound);
queue.addEventListener(...);
queue.loadManifest([{id:"sound1",src:"sound/ogg/sound1.ogg|sound/mp3/sound.mp3"}]);

The error is on this function:

c.parsePath = function (a, b, g, f) {
a = a.split(c.DELIMITER);
b = {
    type: b || "sound",
    id: g,
    data: f
};
g = c.getCapabilities();
f = 0;
for (var h = a.length; f < h; f++) {
    var k = a[f],
    m = k.match(c.FILE_PATTERN);
    if (null == m) return !1;
    var p = m[4],
    m = m[5];
    if (g[m] && -1 < c.SUPPORTED_EXTENSIONS.indexOf(m)) return b.name = p, b.src = k, b.extension = m, b
    }
    return null
};

The line with error is the if(g[m]...)

My firefox version is 20.0, I'm running it on Mac

Updating CDN

First of all, thanks for creating use a useful and feature-rich library!

I've created a fun little application using SoundJS. It works great in every browser except Firefox due to this issue. In the comments, you guys said you have fixed the problem but you haven't updated the CDN. I'd really appreciate it if you could bump the CDN version.

Thanks!

iPad: When ran from home screen, disables HOME button

Hi,
I am using SoundJS 0.4.0, however I tried to use NEXT version too (which is latest today).

I found an issue, that I can't find any way to solve. When my web app is ran from browser, it's all fine. But if I add it to home screen, and then try to run from home screen, once the audio is played, it disables Home button. App is working fine, without any lag or slowness, but it seems that home button crashes. Do you know how to solve this?

Thanks,
Vladas

Fail to play sound on IE

Example:
var sound_manifest = [
{id:"music_menu", src:"res/music_mainmenu.mp3 | res/music_mainmenu.ogg"},
];

Sound can not being play because there is redundant space between ".mp3" and "|". Fail to load resource because soundjs detected that sound extension is "mp3 ", not "mp3".
This bug does not happens on Chrome

Tested in window 8

Channels not working in 0.4.0 and Firefox

When upgrading from 0.3.0 to 0.4.0, multi-channel playback stopped working in Firefox. This seems to be a SoundJS issue as 0.3.0 still demonstrates the correct behaviour.

I created a demo of this:

http://createjs-amd.herokuapp.com/

The sound works and multi channel playback works correctly with the 0.3.0 libraries. With 0.4.0 it seems only one channel can play at a time.

Everything works great in Chrome, especially with the new WebAudio API support.

Ref:
http://community.createjs.com/discussions/soundjs/119-no-multi-channel-sound-in-firefox-htmlaudioplugin-since-v040

registerSound doesn't fail or callback on duplicate call to long file

I first call
createjs.Sound.registerSound()

in response to a user action, to preload an mp3 that takes a very long time to load.

The registerSound() hasn't yet called back (it's a slow internet connection) when my user clicks that same mp3 to play again.

And so I reissue the registerSound() command again with the same mp3,

Here's the bug: that 2nd call never issues a callback, nor does it return an obvious error message.

I've registered listeners for fileload, complete and error, but none get called on that 2nd call to registerSound().

Furthermore, the object returned by the 2nd call to registerSound() doesn't seem to indicate that an error has occured.

Is this a bug? It seems to me that registerSound() should always issue a callback, of at least one of these types of events: fileload, complete, error.

I know, I should detect that there's a pending registerSound() for that mp3, but it seems to me that a duplicate registerSound() call should fail or complete in an obvious way.

-john

If you play long audio twice before it's finished, you won't be able to stop it

Version 0.3.0
Tried in browsers: Chrome 24.0.1312.57m and Firefox 18.0.1 (though I don't think it's browser related)
Can be easily reproduced in a SoundGrid.html
Set Machinae Supremacy track to id 1
Then run twice

createjs.SoundJS.play(1);

And then try to

createjs.SoundJS.stop(1);

it won't stop no matter how many time you try

If it's fixed in NEXT version, could please point to commit or provide a patch.
Many Thanks.

Preload and Play sound in IE8 not working

I tried to preload and play an audio in IE8 but it's not working. I did my test with the version NEXT of your PreloadJs and SoundJs (of the version 4.1) using Flash plugin and this is were it crashes.

I then tried running your example that was on your website (SoundJS-release_v0.4.1/examples/PreloadAndPlay.html) and i'm getting this error:

Sorry!
SoundJS is not currently supported in your browser.
Please log a bug with the device and browser you are using. Thank you.

Do you support IE8?

If so, what would be the steps to follow to get it to work

[FlashPlugin] Short delay before playback

Hey guys,

I'm using CreateJS for the sound of an HTML5 game. I failed to make the background music loop gaplessly with the HTML Plugin, so I force the use of Flash. Now I also want to use it for sound effects (button clicks, game effects) which need to be played immediately when they are triggered. Unfortunately I've noticed that there's a short delay before the playback starts. It can also be observed in you example:
http://www.createjs.com/Demos/SoundJS/TestSuite.html?type=flash
(Tested in Firefox and Chrome; it's easier to hear in Firefox.)

Now it would be nice to use the FlashPlugin for the BGM and the HTML Plugin for other effects - is there a workaround to do so?

Or maybe there's even a way to remove the gap?

Any feedback is much appreciated!
Cheers
Robert

setPosition() and stop() not working on Chrome

Whenever I go back to play a sound instance that was previously playing, Chrome always picks right up at the point where that instance was playing (ie, as if pause()/play() had been used).

Calling stop() or setPosition(0) on the previously-used instance has no effect.

I haven't had this problem on other browsers, they work as expected.

Current workaround: delete and recreate the sound instance.

-john

SoundJS Flash Plugin is a white pixel in firefox

In FireFox the FlashAudioPlugin is not transparent by default, and on a non-white page-backround it will be a visible 1x1 pixel. I fixed this by adding this to swfobject.embed:
var params = {wmode:"transparent"};

I'm not sure if this is the best way to do it, but it worked for me, in case you want to add this.

Delays while preloading sounds with FlashPlugin

Issue found in NEXT 0.4.0 version with latest Firefox, Chrome, IE.

[20:58:25.931] init
[20:58:26.081] Register assets/snd/test.mp3
[20:58:26.095] Register assets/snd/test2.mp3
... 7873 ms delay
[20:58:33.968] preload error
[20:58:34.477] Preload Complete p0
... 7490 ms delay
[20:58:41.967] preload error
[20:58:41.967] preload complete
[20:58:41.972] Play Sound s1 assets/snd/test.mp3 o: 0 l: 0 v: 1 p: 0 mv: 1
[20:58:41.976] Play Sound s2 assets/snd/test2.mp3 o: 0 l: 0 v: 1 p: 0 mv: 1

Wrong getDuration() value in HTMLAudio

As I'm still trying to get setPosition and getDuration() via sliding ui's working, I think there is another issue to be fixed.
Using together PreloadJS and SoundJS I get different duration ( instance.getDuration() ) values of a mp3 file. In chrome (via webaudio) the value is right (e.g. 78000.00ms), but in IE and Firefox (via HTMLAudio) the value is almost double the length (e.g. 131000.00ms).
Did anyone make similar experiences? Is this really an issue?
Thanks in advance,
Schorsch
Update 2013/05/22
I found that HTMLAudio just reads the tag in the mp3 file. And there was the wrong value. I have to search, if there is a problem with the CreateJS Toolkit for Flash, or if the original source soundfile was already corrupted.

Sorry for the false alarm.

Clean up of non-existing instances

I called SoundJS.play with wrong parameters, such as an unknown id, so that the SoundInstance was not fully created. Still the function HTMLAudioPlugin.cleanUp was called which in turn called SoundJS.playFinished. Since instance was never pushed to the array, indexOfis -1 and splice removes the first array element.
Below is my fix, unfortunately I'm not yet familiar enough with GitHub to create a Pull Request.

Looking for your feedback and thanks for this great library!

s.playFinished = function(instance) {
    SoundChannel.remove(instance);

    var index = this.instances.indexOf(instance);
    if (index != -1)
        this.instances.splice(index, 1);
    // Note: Keep in instance hash.
}

Play sound two times

Hi,

I´m building an app with SoundJS, it have 10 elements (each one with its audio). It plays fine the first time, but when going for the 10th o the 1st, it doesn´t play the sound again. I try to debbug it and the only difference i can see is that the first time i play the sound it´s playState="playFinished", and the second time it´s playState="playSucceeded". The second time the audio is played, it nevers triggers the onComplete event.

This is how i play the audio:
var instance = createjs.SoundJS.play(nextAudioID, createjs.SoundJS.INTERRUPT_ALL, 0, 0, false, 1);

Does anyone has this poblem? Can´t see why it´s failing the second time...

Thanks a lot

IE8 throwing error when trying to use flash playback

Hello,

I am having issues making this work in html. I am using SoundJS-Next and preloadJS-0.2.0
I went as far as to try to initialize a separate flashplugin instance when it detects IE but I get the same error all the time. Here is the code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=7;IE=8;IE=9;IE=edge" />

<script type="text/javascript" src="lib/preloadjs-0.2.0.min.js"></script>
<script type="text/javascript" src="lib/soundjs-NEXT.min.js"></script>
<script type="text/javascript" src="lib/soundjs.flashplugin-NEXT.min.js"></script>

<script type="text/javascript" src="http://www.ti.com/lsds/iwov-resources/js/jquery-1.7.2.min.js"></script><!--ls:end[script]-->

<script type="text/javascript">

var preload,instance,flashVal;
var initSound = function(){

    if ($.browser.msie && parseInt($.browser.version) < 9) {
        createjs.FlashPlugin.BASE_PATH = "lib/";
        createjs.Sound.registerPlugins([createjs.FlashPlugin]);
        var assetPath = "mp3/";
        var manifest = [{"id":"1","src":assetPath+"bizness.mp3|"+assetPath+"bizness.ogg","data":1}];
        preload = new createjs.PreloadJS();
        preload.installPlugin(createjs.Sound);
        preload.loadManifest(manifest);
        setTimeout(function(){
            alert('waited 3 seconds');
            playMe();
        },3000);
    } else {
        createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);
        var assetPath = "mp3/";
        var manifest = [
            {"id":"1", "src":assetPath+"bizness.mp3|"+assetPath+"bizness.ogg","data":1}
        ];
        preload = new createjs.PreloadJS();
        preload.installPlugin(createjs.Sound);
        preload.loadManifest(manifest);
        //instance = createjs.Sound.play("song", createjs.Sound.INTERRUPT_NONE, 0);
        //run playMe() in console
    }


}

var playMe = function(){
    instance = createjs.Sound.play("1", createjs.Sound.INTERRUPT_NONE, 0);
}

$(function() {
    initSound();
});

</script> 
</head>

<body>
</body>
</html>

IE9 can only (pre)load max. 41 audio files; maybe also iPad affected

Undocumented IE behavior

IE9 (and IE10?) has an internal limit of 41 simultaneous audio and video elements/objects. The 42nd won't be loaded.

It seems to me (without having tested it enough) that this is a "global" limit, affecting all open tabs, and not only a single html document. So it might be that one can load less than 41 audio/videos.

SoundJS/PreloadJS bug

PreloadJS with the SoundJS plugin creates an audio object for each loaded file. So if you load to many audio files, some will will not load - and the error event will be raised containing an valid HTMLAudioElement, which won't play.

The sound will play at random on your site (depending which loaded first). Also videos won't play after preloading sounds.

I reckon that even without preloading SoundJS will not be able to play more than 41 sounds.
I am not sure, but it seems that HTMLAudioPlugin keeps the played audio elements in memory.

Possible solution
  • Don't create HTMLAudioElements when preloading (at least in IE). This would affect existing code of developers using the library.
  • Reuse the max. 41 "slots" when playing sound on IE.
Further information

It took me almost a day to find this piece of information - more or less by accident :(
This is the only information i could find:

If you find an official documentation of this limit, I would be glad if you let me know.

iPad bug?

We also found a very weird behavior on the iPad (with WebAudioPlugin). At some point our sounds sounded completely distorted and also played to slow. (The sound files are fine, it also occurs with sound files from you demos.) At the beginning of the project everything was ok (we used less sounds them).

I also assume that we are preloading to many sound files, but I don't have the time to isolate the error. (If one sound is distorted, subsequently sound may also be - even in other tabs. You must then quit (not only close) Mobile Safari and delete the cache to have a "clean" state for testing.)

Sorry, but currently I have no time to create a test page. If you need one it will take some time.

How know that sound and is playing

How know that a sound is already playing? , I have a problem that sounds overlap, try something simple 2 button both reproduce the same sound [one song] :/ overlapping sounds, help me please: D

WebAudioPlugin not registering correctly when running Chrome from local file

Running the TestSuite.html test-app from the website works fine. It registers, detects and uses the WebAudioPlugin correctly.

Running the same TestSuit.html test-app from local harddisk (downloaded from github trunk) doesn't work and it reverts to the HTMLAudioPlugin (forcing the code to register only WebAudioPlugin doesn't work, resulting in a message that Chrome doesn't support SoundJs).

What gives?

Audio playback of larger files is interrupted in Chrome

Issue

The playback of the http://www.tons-of-slack.net/soundjs/longaudio.mp3 file freezes after three seconds.

Platform : Google Chrome 19.0.1084.52

Repro :

<html>
  <head>
    <title>
        REPRO
    </title>
  </head>
  <body>
    <script src="http://code.createjs.com/preloadjs-0.1.0.min.js"></script>
    <script src="http://code.createjs.com/soundjs-0.2.0.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">

$(document).ready( function() 
{
  var audioFile = { src: 'http://www.tons-of-slack.net/soundjs/longaudio.mp3', type : PreloadJS.SOUND, id : 'somesound' };

  preload = new PreloadJS();
  preload.installPlugin(SoundJS);
  preload.onComplete = function() 
  {
    var sound = SoundJS.play('somesound');
    var intervalId = setInterval( function() { console.log(sound.getPosition());  }, 20 );
    sound.onComplete = function() { clearInterval(intervalId); }
  }
  preload.loadFile(audioFile);
});
    </script>
  </body>
</html>

Notice that the sound freezes after 3 seconds or so.

Expected : The sound is played entirely.

Notes : It plays correctly in the latest canary build. I believe that onComplete is never called.

WebAudioPlugin.js cleanUpAudioNode(this.sourceNodeNext) Error on null

Hi,
this is my first contribution to github and SoundJS.
I'm using SoundJS 0.4.1.
I found an problem in WebAudioPlugin.js:
When invoking setPosition or pause you shoud check
this.sourceNodeNext, if it's null, like you do in the cleanUp method,
because cleanUpAudioNode(this.sourceNodeNext) throws error, when it is not looped.
Just copy these few lines to setPosition or pause

if (this.sourceNodeNext) {  // this is null unless we are looping
    this.cleanUpAudioNode(this.sourceNodeNext);
}

Thanks,
Schorsch

iPad 1 is unsupported

It appears that the iPad 1 Safari browser in iOS 5 does not support SoundJS. Is this a confirmed issue?

"testAudioStall is not defined" in Chrome

I was getting "testAudioStall is not defined" errors in Chrome when using the minified version in lib.
However I do not get those errors when I built the package myself. Maybe an older version in lib?

Sound isn't playing on Blackberry Playbook inside App

Sound is not playing if App is packed and installed on device.

I've created a HTML5 javascript game, which uses easeljs and soundjs.
The Sound which is a background music is being played fine if i open the html File with the Blackberry Playbook Browser and also works well in Ripple Chrome Playbook Simulator, but if i pack to .bar File and install it on Playbook Sound isn't played anymore.

Fix for: Permission denied to access property 'toString'

Hi guys,
when developing a game that runs in an iframe (Facebook canvas) I encountered this error message in the JavaScript console:

Permission denied to access property 'toString'

I'm using the Flash plugin and it turned out to be a security mechanism of Flash, which disallows to pull content from another domain. Although the Flash plugin and MP3s are hosted on the same domain, the iframe let's Flash consider it as a cross-domain access. The domain, from which the content should be downloaded, needs to allow the access.

To solve this issue I had to place a crossdomain.xml file in the root of our domain.

<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*" />
    <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

I know this is not an error report, but I'm certain someone else will hit the same problem, hence I want this knowledge to be shared.

Cheers,
Robert

Sources:

Using <source> tags to enable multiple audio format support.

Safari lacks Ogg support, and Firefox and Chromium do not support Mp3. This is much more future proof than the current solution of swapping the file extension for different browsers.

For example, what if chrome dropped ogg in favor of some webm-like audio format. Code would have to be updated, existing assets would need to be converted.

If the source tag were to be used, then the developer could change

SoundJS.filetypes = ["ogg", "mp3", "m4a"] to SoundJS.filetypes = ["ogg", "mp3", "m4a", "weba"] without having to fiddle with documentation of the audio formats that a browser supports.

The browser would only load the format that it needs.

Firefox always returns getDuration() of Infinity

Calling getDuration() on a sound instance is always returning "Infinity" for me, perhaps because the instance is based on an http:// mp3 file rather than a local file.

Chrome and Safari are not exhibiting this behavior.

Is there another way of determining the length of a file to work around this?

-john

Handle users who have downloaded the "wrong" Safari on Windows

I just came across this today. I've just set up a new machine (windows 7) and SoundJS wasn't working on my fresh install of Safari.

According to Scott Schiller: "If you download “Safari” alone on Windows, you will not get HTML5 audio/video support (tested in WinXP). You need to download “Safari + QuickTime” to get HTML5 audio/video support within Safari" http://24ways.org/2010/the-state-of-html5-audio

Apparently this is still true.

Anyway, if you have downloaded the "wrong" version of Safari, SoundJS throws this error:

"TypeError: 'undefined' is not a function (evaluating 'a.canPlayType("audio/mp3")')"

We should fall back to another SoundJS plugin in this case.

Not falling back to flash for unsupported browsers.

Perhaps I'm doing something wrong here. I'm building a site that also needs to work on IE7-8 to some extent, I figured soundJS was supposed to fallback to flash for unsupported browsers, but it doesn't seem to be doing that.

I'm including all these classes
SoundJS.js
swfobject.js
HTMLAudioPlugin.js
FlashPlugin.js

and setting the base path for createjs.FlashPlugin, but browsers that don't support html5 audio still seem to be running through HTMLAudioPlugin and throwing errors. I tried wrapping htmlaudioplugin in a modernizr conditional, but that caused other errors in soundjs. has anyone had any luck getting it to revert to flash for older browsers?

Update: wrapping lines starting at 99 in htmlaudioplugin like so allows the site to run on ie8, but also disables the audio.

if(Modernizr.audio) {
var c = s.capabilities = {
panning: false,
volume: true,
mp3: t.canPlayType("audio/mp3") != "no" && t.canPlayType("audio/mp3") != "",
ogg: t.canPlayType("audio/ogg") != "no" && t.canPlayType("audio/ogg") != "",
mpeg: t.canPlayType("audio/mpeg") != "no" && t.canPlayType("audio/mpeg") != "",
wav:t.canPlayType("audio/wav") != "no" && t.canPlayType("audio/wav") != "",
channels: s.MAX_INSTANCES
};
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.