Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having two tabs to show two different TV channels, but when I switch between tabs, their activity(intent) keep running, and they mix up. how can I make sure one channel stops playing before the new one starts?

Here is the code for Activity class:

Java
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoview);
    extras = getIntent().getExtras();
    progressDialog = ProgressDialog.show(TvMenuOne.this, "TV1",
            "Please Wait..", true, true);
    PlayVideo();
}

private void PlayVideo() {
    try {
        videoView = (VideoView) findViewById(R.id.surface_view);
        if(extras.getString("id").equals("one")){
            videoView.setVideoPath(pathL);
        }
        if(extras.getString("id").equals("two")){
            videoView.setVideoPath(pathM);
        }

        videoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
        videoView.setMediaController(new MediaController(TvMenuOne.this));

        videoView.setOnPreparedListener(new OnPreparedListener() {

            public void onPrepared(MediaPlayer mp) {
                progressDialog.dismiss();
                videoView.start();
            }
        });

    } catch (Exception e) {
        progressDialog.dismiss();
        System.out.println("Video Play Error :" + e.toString());
        finish();
    }
}
Posted
Updated 23-Aug-20 2:21am
v2
Comments
AndroidVivek 1-Jan-13 5:58am    
Use asynch task here

1 solution

after playvideo()
progressDialog .Dismiss();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900