静音YouTube的声音在德尔福TWebBrowser [英] Mute YouTube sound in Delphi TWebBrowser

查看:183
本文介绍了静音YouTube的声音在德尔福TWebBrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码德尔福2010年的小视频previewing工具,但我想静音的视频编程,因为正如我所说,这是为previews。

I'm coding a small Video Previewing tool in Delphi 2010, but I want to mute the videos programmatically, because as I said, it's for previews.

我已经试过这code的多个版本,但它总是会导致一个脚本错误,并在年底这是无法做到这一点。

I've tried several versions of this code, but it always results in a script error, and in the end it's unable to do it.

WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, doc);
doc.parentWindow.execScript( 'document.getElementById("movie_player").mute()', 'javascript' );

也试过等待一段时间的控制来完成浏览,但仍然一无所获。

Also tried to wait a little longer for the control to complete browsing, but still nothing.

推荐答案

试着拨打TWebBrowser的的 OnDocumentComplete 事件。当文件里面满载此事件被激发,所以对象,如果它希望在那里,是已经下载并为present。如果没有你的JavaScript code的展示,我不能告诉你更多。

Try to call your code in TWebBrowser's OnDocumentComplete event. This event is fired when the document inside is fully loaded, so the object, if it's expected to be there, is already downloaded and is present. Without showing of your JavaScript code I can't tell you more.

不过,我会做不同的看法。我将执行code一样的这个直接进入您的导航网页。它可以立即关闭声音在 onYouTubePlayerReady 的事件处理程序是什么指时立即YouTube播放器满载。它比调用函数以后,因为它可能会产生由于TWebBrowser的导航完成和您的code的执行之间有一些延迟一短声一阵更好。

But I would do it differently. I would implement code like this one directly into your navigated web page. It can mute the sound immediately in the onYouTubePlayerReady event handler what means immediately when the YouTube player is fully loaded. It's better than call the function later on because it may produce a short sound burst because of some delay between the TWebBrowser's navigation completion and execution of your code.

这篇关于静音YouTube的声音在德尔福TWebBrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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