android - Accessing an audio file in the RAW folder -


i have created new java file within project , trying access war audio file in raw folder. have idea doing wrong?

 mediaplayer mediaplayer;  context context;   public audio()   {      int resid =   context.getresources().getidentifier("morse","raw",context.getpackagename());      context.getresources().openrawresource(resid);     mediaplayer = mediaplayer.create(this.context, resid);  } 

you have failed start media player. try following code,

mediaplayer mediaplayer; context context;

public audio()   {      int resid =   context.getresources().getidentifier("morse","raw",context.getpackagename());      context.getresources().openrawresource(resid);     mediaplayer = mediaplayer.create(this.context, resid);     //start media player     mediaplayer.start();  } 

hope helps!!!...


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -