Omid Naji
Omid Naji

Reputation: 147

If VideoView Equal Null (if do not Exist video path)

I'm using a VideoView in an Android project and need to know if it is empty (null) or not.

How can I recognize whether a VideoView is empty or not?

I tried both of the following methods but neither worked.

if (videoView.equals(null)){

}else{

}

Or

if (videoView == null){

}else{

}

Upvotes: 0

Views: 639

Answers (1)

Akeshwar Jha
Akeshwar Jha

Reputation: 4576

As evident from your problem, you want to find out if the Video file exists or not at a given path. You can simply check it as you'd check for the existence of any other file:

File file = getContext().getFileStreamPath(FILE_NAME);

if(file.exists()){
    //play the video here
} else {
    //maybe show a toast message that the video file doesn't exist
}

Upvotes: 1

Related Questions