首页 \ 问答 \ 使用jquery暂停mediaelement.js(Pause mediaelement.js using jquery)

使用jquery暂停mediaelement.js(Pause mediaelement.js using jquery)

我已经使用下面的元素初始化元素:

$('video').mediaelementplayer();

现在我想定位该视频并在按下链接时暂停它:

$('.page_button').live('click', function() {
    $('video').pause();
});

谢谢。


I have initialised the element using:

$('video').mediaelementplayer();

Now I would like to target that video and pause it when a link is pressed:

$('.page_button').live('click', function() {
    $('video').pause();
});

Thanks.


原文:https://stackoverflow.com/questions/7729305
更新时间:2023-03-25 11:03

最满意答案

是的,这是F#那件闪亮盔甲的瑕疵。 我不觉得有一个通用的解决方案可以轻松地继承或扩展记录。 毫无疑问,人们对此有兴趣 - 我已经计算了十几个用户提交的提交内容,这些内容主要是根据这些方面进行改进的 - 这里有几个主要的提案,可以投票: 1,2,3,4,5

当然,有些事情可以解决这个问题,根据你的情况,它们可能对你很好。 但最终 - 他们是解决方法,你必须牺牲一些东西:

  • 使用反射时速度和类型安全,
  • 当你采用安全的方式并拥有完整的记录和转换功能时,
  • 当您决定退回到纯.NET类和继承时,记录所有的语法和语义优点都可以免费使用。

类型提供者不会削减它,因为它们不是一个真正的元编程的好工具。 这不是他们设计的。 如果您尝试以这种方式使用它们,您肯定会遇到一些限制。

首先,你只能根据外部信息提供类型。 这意味着尽管你可以有一个类型提供者,它可以通过反射从.NET程序集中提取类型,并提供一些基于它的派生类型,但是你不能“内省”到你正在构建的程序集中。 所以没有办法从早先在同一个程序集中定义的类型派生。

我想你可以通过围绕类型提供者构建你的项目来解决这个问题,但这听起来很笨拙。 即使如此,你仍然无法提供记录类型,所以你最好做的就是纯.NET类。

对于为数据库提供某种ORM映射的更具体的用例 - 我想你可以使用类型提供者就好了。 只是不作为一个通用的元编程设施。


Yes, that's a chink in F#'s otherwise shiny armor. I don't feel there's a universal solution there for easily inheriting or extending a record. No doubt there is an appetite for one - I've counted over a dozen uservoice submissions advocating improvements along these lines - here are a few leading ones, feel free to vote up: 1, 2, 3, 4, 5.

For sure, there are things you can do to work around the problem, and depending on your scenario they might work great for you. But ultimately - they're workarounds and there's something you have to sacrifice:

  • Speed and type safety when using reflection,
  • Brevity when you go the type safe way and have full-fledged records with conversion functions between them,
  • All the syntactic and semantic goodness that records give you for free when you decide to fall back to plain .NET classes and inheritance.

Type providers won't cut it because they're not really a good tool for metaprogramming. That's not what they were designed for. If you try to use them that way, you're bound to hit some limitation.

For one, you can only provide types based on external information. This means that while you could have a type provider that would pull in types from a .NET assembly via reflection and provide some derived types based on that, you can't "introspect" into the assembly you're building. So no way of deriving from a type defined earlier in the same assembly.

I guess you could work around that by structuring your projects around the type provider, but that sounds clunky. And even then, you can't provide record types anyway yet, so best you could do are plain .NET classes.

For a more specific use case of providing some kind of ORM mapping for a database - I imagine you could use type providers just fine. Just not as a generic metaprogramming facility.

相关问答

更多
  • 请注意,F#中一个更习惯的方法可能是沿着Seq.tryFind的行使用某些东西,而不是使用LINQ运算符,尽管它不会因为返回一个选项值而Seq.tryFind替换值。 Note that a more idiomatic approach within F# would probably be to use something along the lines of Seq.tryFind rather than to use the LINQ operators, although it's not a d ...
  • 是的,这是F#那件闪亮盔甲的瑕疵。 我不觉得有一个通用的解决方案可以轻松地继承或扩展记录。 毫无疑问,人们对此有兴趣 - 我已经计算了十几个用户提交的提交内容,这些内容主要是根据这些方面进行改进的 - 这里有几个主要的提案,可以投票: 1,2,3,4,5 。 当然,有些事情可以解决这个问题,根据你的情况,它们可能对你很好。 但最终 - 他们是解决方法,你必须牺牲一些东西: 使用反射时速度和类型安全, 当你采用安全的方式并拥有完整的记录和转换功能时, 当您决定退回到纯.NET类和继承时,记录所有的语法和语义优 ...
  • 我认为没有办法告诉F#编译器生成F#记录作为非密封类。 但是,问题是,为什么要存留一条记录? 我的理解是,存根被用来模拟某种类型的某些功能。 但是F#记录是由编译器生成的,所以如果您信任F#编译器,则不需要嘲笑它们,因为它们总是可预测的。 如果你想添加一些成员的记录,那么你可以嘲笑这些。 要做到这一点,你可以定义一个接口,在记录类型中实现它并为接口生成存根: type IFoo = abstract Foo : int -> int type Bar = { Number : int } ...
  • 您应该使用{}来表示记录,而不是() 。 即: type coord = { longitude : float; latitude : float } //Type for a 2D-float-record let myDepthCurve1 = { coords = [ { longitude = 1.; latitude = 2. }; { longitude = 3.; latitude = 4. }]; depth = 9.4 } You s ...
  • 你的意图可以像实现一样简单 let flipMany times switch = match (times % 2) with | 1 -> { switch with State = switch.State.flip } | _ -> switch type Switch = { State : State } member this.Flip = { this with State = this.State.flip } member this.F ...
  • 我尝试将FSharpBinding安装到MonoDevelop 2.8或2.6并且没有成功。 原因是FSharpBinding已过时且与最新版本的MonoDevelop不兼容(请参阅此处的详细讨论)。 首先删除MonoDevelop 2.8或2.6及其相关文件,然后安装MonoDevelop 2.4.2。 你没有提到FSharp和Mono的版本。 一些旧版本可以从http://functional-variations.net/addin repo使用FSharpBinding正常工作。 但是,当我尝试安装 ...
  • 你不必嘲笑。 如果您的依赖项只是函数类型,您可以只提供函数: let mT1= fun x -> 5 对象模拟的整个概念是(必须)由面向对象的人发明,以补偿对象不能很好地组成(或根本不是)的事实。 当您的整个系统正常运行时,您可以在现场创建功能。 不需要嘲笑。 如果你真的忙着使用Foq的设备,比如记录和验证(我建议你重新考虑一下:你的测试会变得更容易,更有弹性),你总能让自己成为一个可以作为你的代理主机的对象。功能: type ISurrogate<'t, 'r> = abstract membe ...
  • F#跨平台包已经过时了。 根据您使用的Linux发行版,F#可能与Mono 2.10.x一起发布(有关详细信息,请查看Mono主页 )。 否则,您应该从源代码构建最新版本的F#编译器 。 原始的F#绑定不适用于MonoDevelop 2.8。 幸运的是, Scott Stephens根据Google Summer of Code项目正在积极开发F#绑定。 这里提到了第一个积极的景象。 有关讨论,您可以在F#开源社区小组发帖或在此处提问。 F# cross-platform package is pretty ...
  • F#记录实际上是使用构造函数生成的,但它似乎不能从F#代码中获得。 可能CompilationMapping属性处理它,因为构造函数本身没有任何属性。 你可以做的是使用标准的.NET反射( Activator.CreateInstance )或FSharp( FSharpValue.MakeRecord , FSharpValue.PreComputeRecordConstructor将为你提供一个函数)使用FSharpValue.PreComputeRecordConstructor函数。 所有这些都希望 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。