Jump to content

Search the Community

Showing results for tags 'audiotag'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. I'm currently working on a jukebox in phaser but i found a big problem, when change more than 17 song mobile devices crushes. I start looking the memory usage on chrome and see that although i use audio destroy, clear game cache, and reset references memory usage keep rise song by song loaded. I could not find a solution in phaser so do the same example with howler, and it happened the same, the use of memory kept going up. Search the forums and find this interesting solution / advice that incredibly worked Is it possible to use the html5 tag in one audio and the webaudio Api in another on phaser? or fix the high memory usage? With this solution in my example i pass from 400mb on memory to 80mb on memory. The code: phaser-howler: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create ,update: update}); function preload() { game.load.spritesheet('button', 'assets/flixel-button.png', 80, 20); game.load.bitmapFont('nokia', 'assets/nokia16black.png', 'assets/nokia16black.xml'); game.load.json('audios', 'assets/audios.json', false); } var currentSong; var songList; var prevSong; var nextSong; var currIndex = -1; var logYPosition = 0; var logYSeparation = 2; var fontSize = 16; var currentTextLog; var timer = 0; var initTimer = 0; var downloadTime = 0; var decodingTime = 0; var songLength = 0; var audioFolder = ""; var repTime = 1*1000; var volume = 0.5; var readyToplay = false; var ended = false; var tempjs = undefined; function create() { tempjs = game.cache.getJSON('audios'); game.stage.backgroundColor = "#FFFFFF"; songList = tempjs.files; audioFolder = tempjs.audiosource; startNextSong(); } function startNextSong(){ currIndex++; initTimer = 0; downloadTime = 0; decodingTime = 0; songLength = 0; if(currIndex>songList.length) { game.add.bitmapText(10, logYPosition + 7, 'nokia', "no more songs in playlist", fontSize); ended = true; return; } logYPosition += fontSize + logYSeparation; var audios = _getAudioFilesArray(audioFolder,songList[currIndex],tempjs.audiotypes); initTimer = game.time.time; currentSong = new Howl({ src: audios, html5: true }); currentSong.once('load', songLoadComplete); currentTextLog = game.add.bitmapText(10, logYPosition + 7, 'nokia', "Downloading song " + currIndex, fontSize); } function songLoadComplete(){ downloadTime = game.time.time - initTimer; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ " Decoding file..."; initTimer = game.time.time; currentSong.play(); readyToplay = true; } function _getAudioFilesArray(audioFolder,audioName,audiotypes){ var returnArray = []; for(var audiotype in audiotypes){ var audio = audiotypes[audiotype]; returnArray[audiotype] = audioFolder+audioName+audio; } return returnArray; } function update(){ if(ended){ return; } if(currentSong!= undefined && currentSong.playing() && readyToplay){ var playingTime = (repTime - currentSong.seek()*1000); currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ "ms Decoding time: " + decodingTime + "ms Playing " + playingTime; } if(currentSong!= undefined && readyToplay && currentSong.playing() && (currentSong.seek()*1000>repTime)){ currentSong.stop(); currentSong.unload(); currentSong = undefined; readyToplay = false; startNextSong(); } } phaser-only: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create ,update: update}); function preload() { game.load.spritesheet('button', 'assets/flixel-button.png', 80, 20); game.load.bitmapFont('nokia', 'assets/nokia16black.png', 'assets/nokia16black.xml'); game.load.json('audios', 'assets/audios.json', false); } var currentSong; var songList; var prevSong; var nextSong; var currIndex = -1; var logYPosition = 0; var logYSeparation = 2; var fontSize = 16; var currentTextLog; var timer = 0; var initTimer = 0; var downloadTime = 0; var decodingTime = 0; var songLength = 0; var audioFolder = ""; var repTime = 1*1000; var volume = 0.5; var readyToplay = false; var ended = false; var tempjs = undefined; function create() { tempjs = game.cache.getJSON('audios'); game.stage.backgroundColor = "#FFFFFF"; songList = tempjs.files; audioFolder = tempjs.audiosource; startNextSong(); } function startNextSong(){ currIndex++; initTimer = 0; downloadTime = 0; decodingTime = 0; songLength = 0; if(currIndex>songList.length) { game.add.bitmapText(10, logYPosition + 7, 'nokia', "no more songs in playlist", fontSize); ended = true; return; } logYPosition += fontSize + logYSeparation; game.load.onLoadComplete.removeAll(); var audios = _getAudioFilesArray(audioFolder,songList[currIndex],tempjs.audiotypes); game.load.audio(songList[currIndex],audios,false); initTimer = game.time.time; game.load.onLoadComplete.add(songLoadComplete, this); currentTextLog = game.add.bitmapText(10, logYPosition + 7, 'nokia', "Downloading song " + currIndex, fontSize); game.load.start(); } function songLoadComplete(){ downloadTime = game.time.time - initTimer; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ " Decoding file..."; initTimer = game.time.time; currentSong = game.add.audio(songList[currIndex],0); currentSong.onPlay.addOnce(songLoadDecode,this); currentSong.play(); } function _getAudioFilesArray(audioFolder,audioName,audiotypes){ var returnArray = []; for(var audiotype in audiotypes){ var audio = audiotypes[audiotype]; returnArray[audiotype] = audioFolder+audioName+audio; } console.log(returnArray); return returnArray; } function songLoadDecode(){ decodingTime = game.time.time - initTimer; console.log(currentSong.isDecoding); currentSong.volume = volume; readyToplay = true; } function update(){ if(ended){ return; } if(currentSong!= undefined && currentSong.isPlaying && readyToplay){ var playingTime = (repTime - currentSong.currentTime)/1000; currentTextLog.text = songList[currIndex] + " download time: "+downloadTime+ "ms Decoding time: " + decodingTime + "ms Playing " + playingTime; } if(currentSong!= undefined && readyToplay && currentSong.isPlaying && (currentSong.currentTime>repTime)){ currentSong.stop(); currentSong.destroy(); console.log(songList[currIndex]); game.cache.removeSound(songList[currIndex]); readyToplay = false; startNextSong(); } }
×
×
  • Create New...