#Is it a good idea to just have the music file with project and stream music with Audio element

8 messages · Page 1 of 1 (latest)

solemn river
#

like this

export namespace GameAudio {
  let music: any;
  export init() {
    music = new Audio('audio.mp4');
  }
  export function playAudio() {
    music.play();
  }
}

audio file is big around 4.x mb, more than 2minutes. Is this the best/secure way??

hasty coral
#

why are you using a namespace instead of a class

neon mist
#

@Bread: Obviously I'm not the OP, but I imagine it's because he wants to "bundle" his variables/methods but doesn't want the additional cruft that comes with classes (e.g. instantiating with new). I dislike how classes are implemented in JS so I tend to avoid them too (although I don't use namespaces as a substitute)

solemn river
#

yes I don't want to pass the object around instead used namespace

grand stream
#

you bolded "secure" in your question… what are you concerned about, exactly? people will be able to download your audio.mp4 file, if that's what concerns you

solemn river
#

I'm not sure but storing the big audio and image files could lead to potential security flaws instead of streaming them from somewhere else? correct me if i'm wrong

#

How can I stream big music files like songs anyone??