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
Post a Comment