views:

60

answers:

2

Hi, Overflow. I have an application which is supposed to convert a video via DirectShowSource.
I have a checkbox which enables a button called "btnviewcrop" which shows a new form called crp.vb for cropping/shearing pixels off the video.

Now, I have a Panel1 that I want to set as the owner (the video drawing surface) but when I set it to open, the application crashes (Error: Object reference not set to an instance of an object.) and I do not understand how to fix it.

Here is my button code:

Imports Microsoft.DirectX.AudioVideoPlayback
Private Sub btnviewcrop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnviewcrop.Click
     Me.ShowInTaskbar = False
     Me.Enabled = False
     crp.Show()
     Dim cropperv As Video
     cropperv.Owner = crp.preview 'VS2010 reports that cropperv has been used before being assigned a value'
     cropperv.FromFile(labinputfile.Text, True)
     cropperv.Play()
End Sub
A: 

I don't think you ever assign anything to cropperv. Did you mean

Dim cropperv As New DirectX.AudioVideoPlayback
Matti Virkkunen
No, I pulled this directly from DevX Source code, and whe changed to AudioVideoPlayback, VS2010 reports the type expected is 'Audio', 'Video' or 'StateFlags'.I forgot to mention I'm working in .NET framework 4.0, and yes I have fixed the incompatible framework problems. (I already have a part of the program getting the height, width, frame-rate and length successfully.)
Yiu Korochko
@Yiu: I have no idea what any of those classes do. My point was not the class name, but the lack of `New`.
Matti Virkkunen
Ah I see what that does now. I need to dim it as a "New" instance because it's not a variable, it is an object.
Yiu Korochko
@Yiu: It's still a variable. A variable that contains a reference to an object, to be exact.
Matti Virkkunen
I have all the initial steps fixed and final now, thank you.I also have a trackbar(vol) for audio, but when I change the slider, nothing seems to happen:Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick cropperv.Audio.Volume = vol.Value / 100End Sub
Yiu Korochko
Nevermind. Turns out the audio property is valid between -1000(min) and 0(max).
Yiu Korochko
A: 

Good point, and if I do this:

Dim cropperv As New Video(labinputfile.Text, True)
cropperv.Owner = crp.preview
cropperv.Play()

Then all works out fine besides the resizing needs done. I appreciate the help, Matti.

Yiu Korochko