kolber / audiojs

A cross-browser javascript wrapper for the html5 audio tag
http://kolber.github.io/audiojs
MIT License
2.1k stars 440 forks source link

IE8 stops on a.element.setVolume(c)}; #51

Closed EnterTheStory closed 12 years ago

EnterTheStory commented 12 years ago

I realize that there are too many browsers and versions and settings to guarantee than any code will ALWAYS work, but I am concerned that when IE8 hits this problem my whole page stops running. Is there any way to use a 'try...catch' or similar that IE8 can then continue? Sorry if this is a beginners type question.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Wed, 30 Nov 2011 00:49:27 UTC

Message: Object doesn't support this property or method Line: 13 Char: 457 Code: 0 URI: file:///C:/game/game%20engine/music/audiojs/audio.min.js

kolber commented 12 years ago

I believe this error is due to a Flash security issue when running files locally. Does it still occur when running off http://localhost or a full domain?

EnterTheStory commented 12 years ago

Thanks for the quick reply. I will find out in the morning and get back to you.

I believe this error is due to a Flash security issue when running files locally. Does it still occur when running off http://localhost or a full domain?


Reply to this email directly or view it on GitHub: https://github.com/kolber/audiojs/issues/51#issuecomment-2953286

EnterTheStory.com: classic books as games

EnterTheStory commented 12 years ago

Sorry, same problem online: It breaks in IE8, Firefox and Opera.

EDIT: the demo page "test6.html" has the same message. Chrome and IE9 work fine.

Firefox 8.01 error: a.element.setVolume is not a function

Opera gives more details: version 11.52 Opera/9.80 (Windows NT 5.1; U; Edition United States Local; en) Presto/2.9.168 Version/11.52

Uncaught exception: TypeError: 'a.element.setVolume' is not a function Error thrown at line 13, column 900 in (c) in http://enterthestory.com/temp3/music/audiojs/audio.min.js: a.element.setVolume(c) called from line 10, column 95 in (e) in http://enterthestory.com/temp3/: audio.setVolume(this.getAttribute('vol')); called from line 3148, column 3 in (event, data, elem, onlyHandlers) in http://code.jquery.com/jquery-latest.js: if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) called via Function.prototype.apply() from line 3781, column 3 in () in http://code.jquery.com/jquery-latest.js: jQuery.event.trigger( type, data, this ); called via Function.prototype.call() from unknown location in (object, callback, args) in http://code.jquery.com/jquery-latest.js: /* no source available */ called from line 271, column 2 in (callback, args) in http://code.jquery.com/jquery-latest.js: return jQuery.each( this, callback, args ); called from line 3780, column 2 in (type, data) in http://code.jquery.com/jquery-latest.js: return this.each(function() { called from line 3832, column 2 in (data, fn) in http://code.jquery.com/jquery-latest.js: return arguments.length > 0 ? called from line 3146, column 16 in volumeNow(vol) in http://enterthestory.com/temp3/scripts/gameEngine.js: $('#' +vol).click();

NOTE: the URLs refer to my sandbox page that has changed since then. The last line is just a jQuery fake click on a playlist based on the test6.html demo.

EnterTheStory commented 12 years ago

I've tried wrapping various parts in try{ } catch(err){) But it doesn't help. If music plays in one browser it freezes other browsers. I can't find any way round this, other than to start my game with a big message "only works in Chrome or IE9" :(

EnterTheStory commented 12 years ago

Whoops! Now I know what the "close" button does. :)

kolber commented 12 years ago

I believe this is caused by a javascript library conflict, but I can't debug it as it looks like you've switched out the library. Everything seems to be working okay for you now, so I'm going to close this issue.

EnterTheStory commented 12 years ago

Fair enough. Thanks for looking into it.

fbiceo commented 12 years ago

hello,I got same problem. After several test, I find in demo/test6.html only work for HTML5 audio tag support. Browser with flash player like IE8 or Firefox 8, it can't use setVolume function. Please give me some suggestion to deal with this problem, thanks.

EnterTheStory commented 12 years ago

I'm afraid I'm not much help. I used SoundManager for a while (it seems to work well, but I feel bad promoting a competitor on the audiojs thread). But ultimately my game suffered from animation problems (nothing to do with sound). I completely redesigned the game, and as a side effect it no longer uses sound at all.

fbiceo commented 12 years ago

SoundManager, that's cool. Thanks for your information! Have a nice day.

crtag commented 12 years ago

There's a bug.

setVolume() is not exposed properly when flash is used instead of native audio tag.

sample code using jQuery to obtain targeted node:

var audio = audiojs.create($('audio').get(0)); audio.setVolume(0.5);

This works fine in Safari/Chrome, fails with reported above error in audioJS code in Firefox (all are most up to date versions) According to firebug, flash is embedded properly and I'm able to play the track, however there are other side effects from this error blocking the rest of debugging.

Minor update - this is impossible to test or reproduce on http://kolber.github.com/audiojs/ just because there's no sample with volume control.

acemir commented 12 years ago

The demo at "http://demo.svnlabs.com/html5player/volume-control/" implements a volume control that works even when the flash callback is in use. I copied the source files and ran on my localhost, but fired the same above mentioned error in browsers that use the flash callback.

IE8 says: Object doesn't support property or method 'setVolume' Firefox says: TypeError: audio.element.setVolume is not a function

I dont know if the problem is just because i'm running it in localhost, and at the moment i have no way to test on a real server.

My desire is to extend the script to allow a volume control even with multiple instances of the player, and currently, my additions are working when it's running with HTML5 and localhost, but I still need to test with Flash on a real server.

xfra35 commented 10 years ago

Hi guys, I broke my head with a similar issue. The simple code below refused to work in Flash mode:

var audioObj=audiojs.create(elem,{css:false});
audioObj.setVolume(0.75);
audioObj.play();

The error raised by Opera was Uncaught TypeError: undefined is not a function.

It appears that one should wait that the SWF is fully loaded before using the flash API.

I fixed it with an ugly poll:

var audioObj=audiojs.create(elem,{css:false});
function audioStart() {
  if (!('swfReady' in audioObj) || ('pplay' in audioObj.element)) {
    audioObj.setVolume(0.75);
    audioObj.play();
  } else
    setTimeout(audioStart,500);
}
audioStart();

But there's surely a smarter way to do it. I'm thinking about the embed load event, although I don't know about the browser support.