首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >axWindowsMediaPlayer:循环上的黑色屏幕

axWindowsMediaPlayer:循环上的黑色屏幕
EN

Stack Overflow用户
提问于 2016-01-08 12:26:02
回答 1查看 1.7K关注 0票数 2

我创建了一个具有axWindowsMediaPlayer控件的Windows应用程序。我还没有在上面创建播放列表,但我已经将.mp4文件存储在特定位置。我通过路径到我的下一个视频在媒体结束了状态。第一次,玩家收到正确的路径和播放。但是对于第二个视频,我只能看到一个黑屏,尽管播放器收到了正确的播放路径。

以下是我的“媒体终止状态”代码:

代码语言:javascript
复制
private void axWindowsMediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
  if(e.newState == 8)
    {
      //Getting jumpTo of selected page
      var selectedElementJumpToValue = MainContentAreaBl.GetSelectedElementValue(_currentId, "jumpTo");
      if (selectedElementJumpToValue != null)
      {
        _currentId = selectedElementJumpToValue;
        if (_currentId != "menu")
        {
          pagination.Text = MainContentAreaBl.GetPaginationText(_currentId);                        
          LaunchPlayer(selectedElementJumpToValue);
        }
        else
        {
          this.Hide();
          this.SendToBack();
          menu.BringToFront();
        }
    }
  }
}

private void LaunchPlayer(string id)
{
  string selectedElementPageTypeValue = MainContentAreaBl.GetSelectedElementPageTypeValue(id);
  var playerFile = Path.Combine(Common.ContentFolderPath, MainContentAreaBl.GetSelectedElementDataPathValue(id));                
  if (selectedElementPageTypeValue == "video")
  {
    InitialiseMediaPlayer();
    axShockwaveFlash.Stop();
    axShockwaveFlash.Visible = false;              
    if (File.Exists(playerFile))               
    {
      axWindowsMediaPlayer.URL = playerFile;
    }               
  }
  else if (selectedElementPageTypeValue == "flash")
  {
    InitialiseShockwaveFlash();
    axWindowsMediaPlayer.close();
    axWindowsMediaPlayer.Visible = false;
    if (File.Exists(playerFile))
    {
      axShockwaveFlash.Movie = playerFile;
      axShockwaveFlash.Play();
    }                
  }
}

private void InitialiseMediaPlayer()
{
  axWindowsMediaPlayer.Visible = true;
  axWindowsMediaPlayer.enableContextMenu = false           
  axWindowsMediaPlayer.uiMode = "none";
  axWindowsMediaPlayer.Dock = DockStyle.Fill;
}

当我调试我的应用程序时,我看到媒体播放器在e.newState == 10 (就绪状态)之后获得了正确的路径。我做错了什么?

编辑1:我发现当我当前的视频进入媒体结束状态后,播放机停止播放。即使我写了axWindowsMediaPlayer.ctlControls.play();,它也不会影响媒体播放器。这是axWindowsMediaPlayer中的一个bug吗?

EN

回答 1

Stack Overflow用户

发布于 2016-12-08 17:54:17

我以前也遇到过这个问题。最有可能的原因是,在播放状态仍在更改时,您正在发出命令axWindowsMediaPlayer.ctlControls.play(); (在Media结束之后,它将更改为Ready状态)。如果在播放状态更改时向玩家发送命令,则不会执行任何操作。导致您的错误的另一个可能原因是,有时需要将媒体状态9(转换)包含在if(e.newState == 8)中,以便您拥有if(e.newState == 8 | e.newState==9)。我也遇到过这样的情况,那就是它没有出现在8州(媒体结尾),可能是因为它发生得非常快,而且过渡到了过渡阶段--对这个原因还不完全确定,但我有一个球员因为这种情况而没有转移到播放列表中的下一个视频。为了解决这个问题,我做了如下事情:

代码语言:javascript
复制
  if (e.newState == 8 | e.newState== 9 | e.newState== 10)
            {
                if (e.newState == 8)
                { //Insert your code here
            }

这将略有不同,取决于您正在努力实现什么。另一件需要注意的事情是使用PlayStateChange事件设置视频URL,这会导致WMP重新输入问题--请参阅其他帖子,以进一步解释我的上一条评论:here is a good oneanother here。希望这能有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34677126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档