Reputation: 168
Here is the code I use to load my video:
VideoView videoView = findViewById(R.id.video);
videoView.setVideoURI(Uri.parse(url));
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setLooping(true);
videoView.start();
loader.loaded.set(true);
}
});
My application contains a "Loading Activity" and I would like to use it to load my video before going to the next Activity.
Is it possible to load a video in an Activity, but to display it in another one?
Thank you for any help you can provide!
PS:
Just in case someone asks, the following line enables me to hide the videoView before it is completely loaded (because a big black square is displayed before the video is fully loaded):
loader.loaded.set(true);
Upvotes: 0
Views: 123
Reputation: 182
You can load the video in the loading activity and store it in a custom class that implements Serializable. Then, you pass the video data with an Intent object while going to the next activity.
Upvotes: 1
Reputation: 2406
You can't move views
between activities. You should instead use Fragments
. Load the video in one fragment and pass it to the other
Upvotes: 1