Youtube API 检测广告 [英] Youtube API detecting advertisements
问题描述
有没有办法检测YouTube广告的播放时间和结束时间?
Is there a way to detect a youtube advertisement, when it is playing and also when it ends?
类似于:
function onPlayerStateChange(event) {
if(event.data == advertisement) {
console.log("Advertisement is playing");
}
if(event.data == advertisementIsOver) {
console.log("Advertisement has finished playing");
}
}
我在这里看到了这个问题:
I see the question here:
前贴片广告期间 YouTube 的 PlayerState 是什么?
我想知道 youtube api 是否有任何更新?另外,有人可以提供一些youtube广告检测器的代码吗?我不确定在播放广告时如何可靠地捕捉.
And am wondering if there are any updates to the youtube api? Also, can someone provide some code of a youtube advertisement detector? I am not sure how one reliably catches when an advertisement is playing.
推荐答案
您可能需要查看此 文档.据说您可以使用 onAdStarted()
在开始播放广告时调用.
You might want to check this documentation. It is stated that you can use onAdStarted()
which is called when playback of an advertisement starts.
Here is a related forum and tutorial which might help.
这篇关于Youtube API 检测广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!