Forums
Basic Video Keeps Locking Computer - Printable Version

+- Forums (http://mitov.com/forum)
+-- Forum: VCL Components (/forum-6.html)
+--- Forum: VideoLab (/forum-19.html)
+--- Thread: Basic Video Keeps Locking Computer (/thread-1281.html)



Basic Video Keeps Locking Computer - CapeCodGunny - 12-23-2012 12:40 PM

I'm using Basic Video with Delphi 2010. In simple terms I've got one TVLDSVideoPlayer, one TVLImageDisplay and three Buttons. Each button triggers the display of a windows media file.

I'm having a hard time finding the correct sequence of Methods and Property calls to keep the application from freezing up. This seems to only happen when the buttons are clicked in rapid succession one after the other.

I purposely have done this to simulate an end user trying to break the application.

What steps and in what order do I need to perform as to prevent the application from locking up?

Any help with be greatly appreciated.

Here is the code for each of the three movie buttons:
----------------------------------------------------
procedure TfmMainScreen.MovieButton1Click(Sender: TObject);
begin
VLDSVideoPlayer1.Pause;
VLDSVideoPlayer1.Stop;
VLDSVideoPlayer1.Close;
Application.ProcessMessages;

VLImageDisplay1.Clear;
VLDSVideoPlayer1.FileName := 'Movie01.wmv';
VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
end;

procedure TfmMainScreen.MovieButton2Click(Sender: TObject);
begin
VLDSVideoPlayer1.Pause;
VLDSVideoPlayer1.Stop;
VLDSVideoPlayer1.Close;
Application.ProcessMessages;

VLImageDisplay1.Clear;
VLDSVideoPlayer1.FileName := 'Movie02.wmv';
VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
end;

procedure TfmMainScreen.MovieButton3Click(Sender: TObject);
begin
VLDSVideoPlayer1.Pause;
VLDSVideoPlayer1.Stop;
VLDSVideoPlayer1.Close;
Application.ProcessMessages;

VLImageDisplay1.Clear;
VLDSVideoPlayer1.FileName := 'Movie03.wmv';
VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
end;


RE: Basic Video Keeps Locking Computer - Dave - 12-23-2012 09:30 PM

The Pause and Paused are pretty much obsolete, other than that it looks fine. Perhaps try without those.

Regards,
Dave


RE: Basic Video Keeps Locking Computer - CapeCodGunny - 12-23-2012 11:57 PM

It still locks the computer. Mad Except does not throw an error, the application just freezes. From within the IDE I have to do a Run > Program Rest. From outside IDE I have to do Task Manager > End Process.


RE: Basic Video Keeps Locking Computer - Dave - 12-24-2012 01:07 AM

Which versions are you using? (lab and compiler)


RE: Basic Video Keeps Locking Computer - CapeCodGunny - 12-24-2012 03:45 AM

(12-24-2012 01:07 AM)Dave Wrote:  Which versions are you using? (lab and compiler)
Delphi 2010 Professional

I'm using a special version of Lab that Boian created for Delphi 2010 to allows the VLImageDisplay to display a smooth output when stretched. The VLImageDisplay includes RenderModes: rmCubic, rmFast, rmLankzos, rmLinear, rmNearestNeighbor, rmSuper

I think I mave have been able to get this to work by setting the VLDSVideoPlayer1.CurrentFrame := (VLDSVideoPlayer1.FramesCount -4) before calling the VLDSVideoPlayer1.Stop method. I'm using an Int64 variable called VideoFrames to set the VLDSVideoPlayer1.CurrentFrame property.

Here is the code I'm using. I know you mentioned that Pause and Paused are practically obsolete, but I have a Pause/Play toggle button that makes use of them. Please let me know if anything glares at you.

----------------------------------------------------------------
procedure TfmMainScreen.MovieButton1Click(Sender: TObject);
begin
MovieButton1.Enabled := False;
Image321.BringToFront;
DisableMovieButtons;
if VideoFrames > 0 then
begin
VLDSVideoPlayer1.CurrentFrame := VideoFrames-4;
Application.ProcessMessages;
end;
VLDSVideoPlayer1.Stop;
StatusBarUpdate(1);

VLDSVideoPlayer1.FileName := 'Movie01.wmv';
VideoFrames := VLDSVideoPlayer1.FramesCount;

VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLImageDisplay1.BringToFront;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
EnableMovieButtons(0);
end;
----------------------------------------------------------------
procedure TfmMainScreen.MovieButton2Click(Sender: TObject);
begin
MovieButton1.Enabled := False;
Image321.BringToFront;
DisableMovieButtons;
if VideoFrames > 0 then
begin
VLDSVideoPlayer1.CurrentFrame := VideoFrames-4;
Application.ProcessMessages;
end;
VLDSVideoPlayer1.Stop;
StatusBarUpdate(2);

VLDSVideoPlayer1.FileName := 'Movie02.wmv';
VideoFrames := VLDSVideoPlayer1.FramesCount;

VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLImageDisplay1.BringToFront;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
EnableMovieButtons(0);
end;
----------------------------------------------------------------
procedure TfmMainScreen.MovieButton3Click(Sender: TObject);
begin
MovieButton1.Enabled := False;
Image321.BringToFront;
DisableMovieButtons;
if VideoFrames > 0 then
begin
VLDSVideoPlayer1.CurrentFrame := VideoFrames-4;
Application.ProcessMessages;
end;
VLDSVideoPlayer1.Stop;
StatusBarUpdate(3);

VLDSVideoPlayer1.FileName := 'Movie03.wmv';
VideoFrames := VLDSVideoPlayer1.FramesCount;

VLImageDisplay1.Visible := True;
TrackBar1.Enabled := True;
PauseButton.Enabled := True;
StopButton.Enabled := True;

// Make sure the component is not paused.
TrackBar1.WindowProc := SliderWndProc;
VLImageDisplay1.BringToFront;
VLDSVideoPlayer1.Open;
VLDSVideoPlayer1.Paused := False;
VLDSVideoPlayer1.Start();
EnableMovieButtons(0);
end;
----------------------------------------------------------------


RE: Basic Video Keeps Locking Computer - Dave - 12-24-2012 05:20 AM

Can't say i see anything out of the ordinary, perhaps it's a problem playing the wmv-files. Maybe you can send a test-project to Boian.

Regards,
Dave


RE: Basic Video Keeps Locking Computer - CapeCodGunny - 12-24-2012 01:55 PM

I've changed the Application.Processmessages to Application.HandleMessage in the above code and it seems faster and cleaner.