Audio not loaded using Libgdx Sound and Music class from app internal storage in android 4.0 -


in senario ,i have used audio file app internal storge.

in android activity class copied phone internal storge app storage. atlas file,png file working audio file not loaded in android version 4.o althogh working in 4.1 , above.

code ...

android project have...

public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          androidapplicationconfiguration cfg = new androidapplicationconfiguration();         cfg.usegl20 = true;         sourcefile = new file(environment.getexternalstoragedirectory().tostring()+"/data/arv.ogg");         if(sourcefile.exists())             log.i("arv", "file exist");         destfile = new file(getapplicationcontext().getfilesdir().tostring()+"/arv.ogg");         log.i("arv", "file dest = "+destfile.tostring());          try {             if(sourcefile.exists())                 log.i("arv", "file status = "+copyfile(sourcefile, destfile));             else                 log.i("arv", "file not found");         } catch (ioexception e) {             log.i("arv", "error not found");             e.printstacktrace();         }          initialize(new frictionscreen(getapplicationcontext().getfilesdir().tostring()+"/"), cfg);     }     private boolean copyfile(file src,file dst)throws ioexception{         if(src.getabsolutepath().tostring().equals(dst.getabsolutepath().tostring())){              return true;          }else{             inputstream is=new fileinputstream(src);             outputstream os=new fileoutputstream(dst);             byte[] buff=new byte[1024];             int len;             while((len=is.read(buff))>0){                 os.write(buff,0,len);             }             is.close();             os.close();         }         return true;     } 

and java project have....

public frictionscreen(string _destfilepath){     filepath=_destfilepath; }     @override     public void create() {           camera = new orthographiccamera(960, 540);         camera.position.set(960 / 2, 540 / 2, 0);         camera.update();         batch = new spritebatch();         music=gdx.audio.newmusic(gdx.files.absolute(filepath+"arv.ogg"));         music.play();         gdx.app.log("arv", "libgdx"+gdx.files.getexternalstoragepath());     } 

getting exception in android 4.0 (4.1 , above working fine)

fatal exception: glthread 834 com.badlogic.gdx.utils.gdxruntimeexception: error loading audio file: /data/data/com.me.frictiongame/files/arv.ogg @ com.badlogic.gdx.backends.android.androidaudio.newmusic(androidaudio.java:131) ............... ...................... caused by: java.io.ioexception: prepare failed.: status=0x1 @ android.media.mediaplayer.prepare(native method) @ com.badlogic.gdx.backends.android.androidaudio.newmusic(androidaudio.java:124) 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -