开发者

why I don't call url from Http request when onCompletion

I want to call new url after My custom Music Player complete played but It do not call and send new url to my player. Help me please thank you.

public void onCompletion(MediaPlayer arg0) 
{
    playing = "Stopped";
    new Thread(new Runnable() 
    {
        @Override
        public void run() 
        {
            now++;
            try
            {
                onCompleteURL = new URL(musicUrl[now]);
                onCompleteURLConnection = onCompleteURL.openConnection(); 
                onCompleteReadIn = new BufferedReader(new InputStreamReader(onCompleteURLConnection.getInputStream()));
                onCompleteUrl = onCompleteReadIn.readLine();
                onCompleteReadIn.close();
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
            waitingGetNextDataHandler1.sendEmptyMessage(0);
        }
    }).start();
    waitingGetNextDataHandler1 = new Handler()
    {
        public void handleMessage(Message msg) 
        {
            super.handleMessage(msg);
            try 
            {
                /*mMediaPlayer.reset();
                sendHTTPRequest();
                startPlayer();*/
                mMediaPlayer.reset();
                mMediaPlayer.setDataSource(onCompleteUrl);
                mMediaPlayer.prepare();
                开发者_高级运维mMediaPlayer.start();
                playing = "Started";
                running = mMediaPlayer.isPlaying();
                playPauseImageButton.setBackgroundResource(R.drawable.pause_button);
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
            if(mMediaPlayer != null)
            {
                if(mMediaPlayer.isPlaying() == true)
                {
                    playPauseImageButton.setBackgroundResource(R.drawable.pause_button);
                }
                else
                {
                    playPauseImageButton.setBackgroundResource(R.drawable.play_button);
                }
                setValue();
            }
        }
    };
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜