JOHN JOHNNNY

JOHN JOHNNNY

  • NA
  • 190
  • 140k

Cannot resolve mediaplayer$onpreparedlistener

Sep 15 2016 7:41 PM
Hi<br /> I am trying to add play/pause/stop to audio file stored in assets folder<br /> the file is to be played from html file in webview. when i tried putting<br /> the code together i am getting this error "cannot resolve MediaPlayer$OnPreparedListener"<br /> see my code below<br /> <br /> @JavascriptInterface<br /> public void playAudio(final String s) {<br /> if (this.mp != null) {<br /> if (this.mp.isPlaying()) {<br /> this.mp.pause();<br /> }<br /> else {<br /> this.mp.start();<br /> }<br /> }<br /> else {<br /> try {<br /> final AssetFileDescriptor openFd = this.mContext.getAssets().openFd(s);<br /> (this.mp = new MediaPlayer()).setDataSource(openFd.getFileDescriptor(), openFd.getStartOffset(), openFd.getLength());<br /> openFd.close();<br /> this.mp.prepare();<br /> this.mp.setOnPreparedListener((MediaPlayer$OnPreparedListener)new MediaPlayer$OnPreparedListener() {<br /> public void onPrepared(final MediaPlayer mediaPlayer) {<br /> }<br /> });<br /> this.mp.start();<br /> }<br /> catch (IllegalArgumentException ex) {<br /> Log.e(this.TAG, "Err-1: " + ex.toString());<br /> ex.printStackTrace();<br /> }<br /> catch (IllegalStateException ex2) {<br /> Log.e(this.TAG, "Err-2: " + ex2.toString());<br /> ex2.printStackTrace();<br /> }<br /> catch (IOException ex3) {<br /> Log.e(this.TAG, "Err-3: " + ex3.toString());<br /> ex3.printStackTrace();<br /> }<br /> }<br /> }<br /> Kindly help

Answers (2)