Video Player-MouseMove问题. [英] Video Player - MouseMove problem.

查看:70
本文介绍了Video Player-MouseMove问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有一个使用DirectX.AudeoVideoPlayback.Video在Visual C#中运行的视频播放器程序.我已经设置了一个控制栏,以便在播放视频时将鼠标移到上方时,控制栏可见,然后在将鼠标移开时不可见.像WMP11一样.

我遇到的问题是,运行程序后,播放第二个视频与播放第一个视频时,视频的行为有所不同.当我第一次打开程序并运行视频时,一切正常.触发MouseMove事件,并(根据指针的位置)确定是否显示该控件.

当我关闭视频并打开第二个视频时,即使触发了MouseMove事件,该事件也不再触发尽管我每次都使用相同的方法来设置和播放视频.

这是我播放电影的代码:

私人

Ok, so I've got a video player program going in Visual C# using DirectX.AudeoVideoPlayback.Video.  I've got a control bar set up so that when you move the mouse over when the video is playing, the control bar is visible and then when you move the mouse away, it is not.  Like WMP11.

The problem I've got is that the Video is behaving differently when I play a second video vs. when I play the first video after running the program.  When I open the program and run the video the first time, everything work's great.  The MouseMove event fires and (based on the location of the pointer) determines whether or not to show the control.

When I close the video and open a second one, the MouseMove event no longer fires, even though I have used the same method to set up and play the video each time.

Here's my code for playing a movie:

private

playCurrentMovie()

{

void playCurrentMovie()

{

字符串 f = myMovies.getMovie(currentIndex).getURL();

String f = myMovies.getMovie(currentIndex).getURL();

 

如果 (validFileType(f))
{
如果 文件 .Exists(f))
{
try
{{br/> .mov = 视频 (f, );
;
( 异常 例如)
{
MessageBox .Show(ex.Message, 电影播放错误" );
}
}
else
MessageBox
" -找不到文件." 电影播放错误" .Show( 路径 "无效类型." 电影播放错误" );

}

只是停止播放电影:

this.mov.Stop();
this.mov.Dispose();

   if (validFileType(f))
  {
      if (File.Exists(f))
      {
         try
         {
            this.mov = new Video(f, false);
            this.mov.Owner = this;
            this.mov.Play();
         }
         catch (Exception ex)
         {
            MessageBox.Show(ex.Message, "Movie Playback Error");
         }
      }
      else
         MessageBox.Show(f + " - File not found.", "Movie Playback Error");
   }
   else
      MessageBox.Show(Path.GetExtension(f) + " is not a valid file type.", "Movie Playback Error");

}

and stopping the movie is just:

this.mov.Stop();
this.mov.Dispose();

推荐答案

初始化第一个视频的所有操作-需要处理然后重新初始化第二个视频视频-在大多数视频播放器中都是如此.

Everything you do to initialise the first video - needs to be disposed of and then re-initialised for the second video - it is how it is done in most video players.

因此,请处理mousemove事件,然后为下一个视频重新初始化它.

So dispose of the mousemove event and re-initialise it for the next video.


这篇关于Video Player-MouseMove问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆