ekelokorpi / panda-engine

Panda Engine - HTML5 Game Engine
https://www.panda2.io
739 stars 101 forks source link

audio.js - pause/resume on cocoonjs #50

Closed ghost closed 10 years ago

ghost commented 10 years ago

I can't pause and resume the sounds from cocoonJS, furthermore, the sound appears jerky.

It should be possible according to the example provided by Ludei, Multichannel Sound.

https://cocoonjsservice.ludei.com/cocoonjslaunchersvr/demo-list/

Am I the only one ?

The test code below works correctly in Chrome and Firefox.

src/game/main.js

game.module(
    'game.main'
)
.require(
    'engine.core'
)
.body(function() {

game.addSound('sounds/music.*', 'music');

SceneGame = game.Scene.extend({
    backgroundColor: 0x808080,

    isPlaying: true,

    init: function() {
        game.audio.playMusic('music');
    },

    mousedown: function () {
        this.isPlaying ? game.audio.pauseAll() : game.audio.resumeAll();
        this.isPlaying = !this.isPlaying;
    }
});

game.System.idtkScale = 'ScaleToFill';

game.start();

});
ghost commented 10 years ago

I know a library with lots of functionality suitable for html5 games. (Sprite, fadeIn, fadeOut ...) I think it would be great to implement it in the engine as core module or plugin.

http://goldfirestudios.com/blog/104/howler.js-Modern-Web-Audio-Javascript-Library

ekelokorpi commented 10 years ago

Have you tested howler.js with CocoonJS?

ghost commented 10 years ago

No but I don't see why it would not work. ;-)

ghost commented 10 years ago

Indeed, I have failed, so I created an issue for the experts. https://github.com/goldfire/howler.js/issues/132

ekelokorpi commented 10 years ago

:+1:

ghost commented 10 years ago

I make a PR. https://github.com/ekelokorpi/panda.js/pull/51 I bet Ludei add Web Audio soon...

ghost commented 10 years ago

https://github.com/goldfire/howler.js/pull/133

:+1: