Quantcast
Channel: Not able to play Sound with this code - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Not able to play Sound with this code

$
0
0

I am using below code in my app to play the Sound.But i am not able to play it.Whats the Problem ??

Code:

public void playSound(int resources){    try{        boolean mStartPlaying = true;        MediaPlayer  mPlayer=null;        if (mStartPlaying==true){            mPlayer = new MediaPlayer();            Uri uri = Uri.parse("android.resource://MY_PACKAGE/"+ resources);            mPlayer.setDataSource(getApplicationContext(),uri);            mPlayer.prepare();            mPlayer.start();        }         else{            mPlayer.release();            mPlayer = null;        }        mStartPlaying = !mStartPlaying;    }    catch (IOException e){        Log.e(LOG_TAG, "prepare() failed");    }}

And i get log cat as like below:

05-09 05:24:22.272: VERBOSE/PlayerDriver(95): Completed command PLAYER_INIT status=PVMFFailure05-09 05:24:22.272: ERROR/PlayerDriver(95): Command PLAYER_INIT completed with an error or info PVMFFailure05-09 05:24:22.272: ERROR/MediaPlayer(8072): error (1, -1)05-09 05:24:22.272: ERROR/AudioPlayTest(8072): prepare() failed05-09 05:24:22.282: VERBOSE/PVPlayer(95): run_set_video_surface s=-2147483648, cancelled=005-09 05:24:22.282: VERBOSE/PlayerDriver(95): HandleInformationalEvent: PVMFInfoErrorHandlingComplete05-09 05:24:22.282: WARN/PlayerDriver(95): PVMFInfoErrorHandlingComplete

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>