Cannot retrieve video while returning back to mediaplayer in android
<p>I m playing a video in mediaplayer from url . when running this mediaplayer in background by clicking the home button,and then retrieving back from the taskmanager , i m getting only a black screen with audio.
can anyone help me..</p>

<p>Thanks in advance</p>

<pre><code>private void playVideo() {
    showPopup();
    new Thread(new Runnable() {
        public void run() {
            try {
                player.setDataSource(URL);
                player.prepare();
            } catch (IllegalArgumentException e) {
                showToast("Error while playing video");
                Log.i(TAG,
                        "========== IllegalArgumentException ===========");
                e.printStackTrace();
            } catch (IllegalStateException e) {
                showToast("Error while playing video");
                Log.i(TAG, "========== IllegalStateException ===========");
                e.printStackTrace();
            } catch (IOException e) {
                showToast("Error while playing video. Please, check your network connection.");
                Log.i(TAG, "========== IOException ===========");
                e.printStackTrace();
            }
        }
    }).start();
}




public void surfaceCreated(SurfaceHolder holder) {

    if (IsPlaying == false) {
        BroadcastReceiver receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub

                ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo activeNetwork = connMgr.getActiveNetworkInfo();
                try {
                    if (activeNetwork != null
                            &amp;&amp; activeNetwork.isConnected()) {
                        playVideo();
                    } 
                    else {
                        Toast.makeText(getApplicationContext(),
                                "Network Connections Unavailable",
                                Toast.LENGTH_LONG).show();
                        finish();
                    }
                }
                catch (Exception e) {
                    Toast.makeText(getApplicationContext(),
                            "Network Connections Unavailable",
                            Toast.LENGTH_LONG).show();
                    finish();
                }
            }
        };
        IntentFilter filter1 = new IntentFilter(
                ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(receiver, filter1);
    } else {
        onPrepared(player);
    }
}
</code></pre>
