Web Worm
Web Worm

Reputation: 2066

using System.Threading.Thread.Sleep(1000) in vb.net

I have list of video files in datagridview object, and I want to play it one after other

I have the following code

For Each dgvRow In bout_shedule.Rows
    vfile = dgvRow.Cells("VideoFile").value
    player.URL = vfile
    player.Ctlcontrols.play()
    System.Threading.Thread.Sleep(duration * 1000)
Next

I also have get the duration of video file; now I want the media player to play the first video and stops the loop; once it finishes playing video, than the loop continues to the 2nd row, but the nothing is going to play at all. How can I solve this problem ?

Upvotes: 0

Views: 3855

Answers (1)

Hassan Syed
Hassan Syed

Reputation: 20485

One thing is for sure, when your application has events, don't go into a polling loop. Your video library interface should have a 'on stop' event that you need to register for. Your code is relying on the fact that the client isn't going to pause the video, or rewind.

You need to find a way to block till the video player object raises a stop event.

This is a link to the interface of the object you are using. It has a section for the events the player offers. You need to register for a certain event (events that represent stopping or the skip/forward button) and react to it. I can't explain further you should read the MSDN documentation or get a book on GUI programming.

Upvotes: 2

Related Questions