简体   繁体   English

在vb.net中使用System.Threading.Thread.Sleep(1000)

[英]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 我在datagridview对象中有视频文件列表,我想一个接一个地播放

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 ? 我怎么解决这个问题 ?

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. 您需要找到一种方法来阻止视频播放器对象引发Stop事件。

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. 我无法进一步解释,您应该阅读MSDN文档或获取有关GUI编程的书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM