0

Play audio on non-IE browsers

asked 2013-07-19 11:28:38 +0800

cocoes gravatar image cocoes flag of Spain
94 6

Hi!

I'm trying to play sounds on certain events using ZK component, but ..

  • Audio component just seems to work with Internet Explorer, not Chrome or Firefox.

The error shown is:

Your browser does not support dynamic audio 
Object #<HTMLEmbedElement> has no method 'Play'

I've seen a closer problem here: http://forum.zkoss.org/question/65301/dynamic-audio-problem/ , and the answer is to use ZK soundmanager , but...

  • Soundmanager component does not seems to work , at least with Chrome I've the following error:

    Cannot call method 'createSound' of undefined (TypeError)

and someone else recommends Quicktime plugin.

Does anyone knows a good and compatible way of playing sound (MP3) events?

I belive it must be a point to develop in ZK future developments, as it's very useful in rich media developments...

Regards,

Vicente

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-07-23 04:07:16 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2013-07-23 04:07:32 +0800

Hi cocoes,

I have created a patch for audio component, please add the following setting to your zk.xml.

<device-config>
   <device-type>ajax</device-type>
   <embed><![CDATA[
      <script type="text/javascript">
         zk.afterLoad('zul.med', function () {
            var _xAudio = {},
                Audio = zul.med.Audio;
            zk.override(Audio.molds, _xAudio.molds = {}, {
                'default': function (out) {
                    var src = this._src || '';
                    out.push('<audio', this.domAttrs_(), ' controls>',
                        '<source src="', src, '" type="audio/mpeg">', 
                        '<embed src="', src, '">', 
                        '</audio>');
                }
            });
            zk.override(Audio.prototype, _xAudio, {
                domAttrs_: function(no){
                    return this.$supers('domAttrs_', arguments);
                }
            });
         });
      </script>
    ]]></embed>
</device-config>
link publish delete flag offensive edit

Comments

Hi Jimmy! Many thanks, it works now with IE and Chrome, but in Safari it says "Your browser does not supports dinamic audio", Opera don't works and Firefox says that "audio/x-mpeg Content-Type HTTP is not compatible. The resource media loading of www.mydom.com/xxx.mp3 has failed".

cocoes ( 2013-07-23 08:02:31 +0800 )edit

Hi, I have tested with firefox 22 it works fine, and test with safari 5.1.7, for safari you have to install quick time player, my OS is win7 64 bit

jimmyshiau ( 2013-07-25 02:41:46 +0800 )edit

Hi again Jimmy. I'm also using Firefox 22, but I guess it works in your Firefox because you have Quick time plugin installed. Quick time seems to be also mandatory for FF.

cocoes ( 2013-07-25 10:43:50 +0800 )edit

I've just installed Quicktime and now it works in Safari, just FF is still not working. Warning on Error cosole still says "audio/x-mpeg Content-Type HTTP is not compatible". At least, no popup error is thrown to the browser...Opera the same as FF.

cocoes ( 2013-07-25 11:21:30 +0800 )edit

I've just seen that FF does not seems to support natively MP3, OGG should be used instead: http://stackoverflow.com/questions/16760955/http-content-type-of-audio-mpeg-is-not-supported-issue-on-firefox Opera not at all... https://developer.mozilla.org/en-US/docs/HTML/Supportedmediaformats

cocoes ( 2013-07-25 11:36:04 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-07-19 11:28:38 +0800

Seen: 13 times

Last updated: Jul 23 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More