I have a project that has 4 radio buttons labeled with different animals. There are then 6 buttons and when a button is pressed based off of the radio button selected a picture will display and specific text will fill a label in the window.
When the user selects Koala (radio button) and presses Talk (button) it will hide the picture box and unhide the object that houses the video.
When I then click any other button/animal combination the video is hidden but still audible. I implemented an if-then statement to check the playback state of the video and if it is not currently stopped then stop it.
The problem becomes if the Koala.Talk has not been performed, the video is not established yet (I instantiated the Video video; earlier in the code though). If the video hasn't started at least once, it gives an error "Object reference not set to an instance of an object." I believe it is because it can't check the videos playback state without it first having been told to play. Here is my if-then statement to check it.
How do I code it to check the playback state, and/or check if the video has been played/established? I want it to reach the code after the if-then statement if the video hasn't been played/playing yet.
Thanks in advance.
When the user selects Koala (radio button) and presses Talk (button) it will hide the picture box and unhide the object that houses the video.
Code:
else if (rbtnKoala.Checked == true)
{
{
lblOutput.Text = Convert.ToString(reggie.Talk);
//hide the picture box
pictureBox1.Visible = false;
//make the video box visible
viewport.Visible = true;
// store the original size of the panel
int width = viewport.Width;
int height = viewport.Height;
//string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
string directory = //directory of file.
// load the selected video file
video = new Video(directory);
// set the panel as the video object’s owner
video.Owner = viewport;
// resize the video to the size original size of the panel
viewport.Size = new Size(width, height);
video.Play();
}
}
The problem becomes if the Koala.Talk has not been performed, the video is not established yet (I instantiated the Video video; earlier in the code though). If the video hasn't started at least once, it gives an error "Object reference not set to an instance of an object." I believe it is because it can't check the videos playback state without it first having been told to play. Here is my if-then statement to check it.
Code:
//this stops the video of koala.talk if it is playing when this button is clicked
if (video.State != StateFlags.Stopped)
{
video.Stop();
}
Thanks in advance.
Comment