首页 \ 问答 \ 如何在WPF中向后播放视频?(How to play video backwards in WPF?)

如何在WPF中向后播放视频?(How to play video backwards in WPF?)

我希望在WPF中顺利播放视频。 我正在使用MediaElement播放视频。 我读过这篇文章建议定期更改MediaElement.Position以模仿倒带行为。

我尝试使用代码来更改MediaElement.Position位置

private void Button_Click(object sender, RoutedEventArgs e)
{
    mePlayer.Pause();                               //Pause the media player first
    double m = 1 / frameRate;                       //Calculate the time for each frame
    double t = 120;                                 //Total length of video in seconds
    mePlayer.Position = TimeSpan.FromMinutes(2);    //Start video from 2 min
    while (t >= 60)                                 //Check if time exceeds 1 min
    {
        t = t - m;                                  //Subtract the single frame time from total seconds
        mePlayer.Position = TimeSpan.FromSeconds(t);//set position of video
    }
}

在上面的代码中,我试图从2分钟到1分钟向后播放视频。 它在mePlayer.Position = TimeSpan.FromSeconds(t)上给我'System.OverflowException'。

如果有人知道如何在WPF中向后播放视频,请帮助我实现此效果。 谢谢。


I want to smoothly play video in backwards direction in WPF. I am using MediaElement to play the video. I read this post which suggests changing MediaElement.Position periodically to mimic the rewinding behaviour.

I tried following code for changing position of MediaElement.Position

private void Button_Click(object sender, RoutedEventArgs e)
{
    mePlayer.Pause();                               //Pause the media player first
    double m = 1 / frameRate;                       //Calculate the time for each frame
    double t = 120;                                 //Total length of video in seconds
    mePlayer.Position = TimeSpan.FromMinutes(2);    //Start video from 2 min
    while (t >= 60)                                 //Check if time exceeds 1 min
    {
        t = t - m;                                  //Subtract the single frame time from total seconds
        mePlayer.Position = TimeSpan.FromSeconds(t);//set position of video
    }
}

In above code I am trying to play video backwards from 2 min to 1 min. It's giving me 'System.OverflowException' on mePlayer.Position = TimeSpan.FromSeconds(t).

If anyone know how play video backwards in WPF, please help me to achieve this effect. Thank you.


原文:https://stackoverflow.com/questions/30955604
更新时间:2024-03-04 19:03

最满意答案

所以我分叉了repo并进行了一些额外的调试,似乎失败的属性为null值。

使用appcmd看起来像

   <redirectHeaders>
</redirectHeaders>

我在代码中检查了null,并将在今天晚些时候提交拉取请求


So I forked the repo and put some extra debug in and it seems like the failure was down to a null value for a property.

Using appcmd it looks like

   <redirectHeaders>
</redirectHeaders>

I've put a check for null into the code and will be submitting a pull request later today

相关问答

更多
  • 听起来你正在寻找applicationHost.config ,它位于C:\Windows\System32\inetsrv\config 。 是的,它是一个XML文件,是的,手动编辑文件会在重新启动后影响IIS配置。 您可以将IIS管理器视为编辑applicationHost.config和web.config的GUI前端。 It sounds like you're looking for applicationHost.config, which is located in C:\Windows\Sy ...
  • 您应该只需添加如下规则: 请求的URL:匹配模式 使用:正则表达式 图案:oldfolder 忽略大小写:是的 动作类型:重定向 重定向网址:htt://www.mysite.com 附加查询字符串:false重定向类型301 For future reference and for anyone else doing a similar thing here's the total rules we ended up using: ...
  • 所以我分叉了repo并进行了一些额外的调试,似乎失败的属性为null值。 使用appcmd看起来像 我在代码中检查了null,并将在今天晚些时候提交拉取请求 So I forked the repo and put some extra debug in and it seems like the failure was down to a null value for a property. Using appcmd it ...
  • WAS是一种进程激活机制,而不是单独的托管环境。 在启用WAS的情况下使用IIS7或更高版本将允许您托管使用非HTTP绑定(如TCP和MSMQ绑定)的应用程序。 优点是您没有顶级创建自己的主机来公开这些类型的端点,您可以利用IIS应用程序管理功能和管理。 WAS is a process activation mechanism not a separate hosting environment. Using IIS7 or higher with WAS enabled will allow you t ...
  • 我发现问题是在jquery.jqGrid.js文件中的var pathtojsfiles。 / scripts / js /在本地工作正常,但在服务器上,我必须使用完整路径http:// servername / project / Scripts / js / “ I found the problem was with the var pathtojsfiles in the jquery.jqGrid.js file. /scripts/js/ works fine locally, but on t ...
  • 我可能是你有两个应用程序/网站使用一个应用程序池,但应用程序/网站运行不同的.net版本。 情况可能不是这样,但它是我曾经遇到的唯一类似的重复问题。 Because of a bug in my Entity Framework I was getting a cyclic call into one of my relationships. This was causing a stack overflow which was reported to WebOrb as a general error a ...
  • 在集成模式下设置应用程序池,并设置所有请求都运行所有托管模块 ... ... Set application pool in integrated mode and set that all request run all managed modules
  • 您需要向以下帐户之一授予权限 ASPNET - Win XP and Win 2000 NETWORK SERVICE - Win Vista and 2003 这些是默认值,如果已为其他进程帐户配置了应用程序池,则需要使用该特定帐户。 You need to grant permission to one of the following accounts ASPNET - Win XP and Win 2000 NETWORK SERVICE - Win Vista and 2003 These a ...
  • 除非使用MVC1, 否则不需要在IIS上具有MVC扩展。 在IIS6上使用无扩展URL可以很好地使用MVC2。 但是,要回答您的问题,请查看以前的问题: 如何使用C#检测IIS版本? You do not need to have an extension for MVC on IIS unless you are using MVC1. MVC2 and up work just fine with extensionless URLs on IIS6. However, to answer your q ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)