我正在测试Youtube Data API V3以通过查询字词获取列表视频,然后在iframe中播放它们.
我收到这个错误:
www-embed-player.js:306 GET https://googleads.g.doubleclick.net/pagead/id?exp=nomnom net::ERR_BLOCKED_BY_CLIENT
经过一些调试和谷歌搜索,我发现这个错误通常是由广告拦截器引起的.然后我在Chrome上禁用了我,然后重新测试了api通话.我不再看到原始错误,:ERR_BLOCKED_BY_CLIENT但检索到的视频无法播放.玩家消息:An error occurred, please try again later.
下面是代码.为简单起见,JS在HTML文件中.
任何帮助赞赏!
<!doctype html>
<html lang="en">
<head>
<title>Youtube API Test </title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous">
</head>
<style>
body {
background-color: #0F0F0F;
}
button.btn.btn-primary {
background-color: #E12523;
border-color: #E12523;
}
div.jumbotron {
background-color: #292929;
color: #B3B3B3;
}
hr.my-2 {
border: 1px solid #B3B3B3;
}
</style> …Run Code Online (Sandbox Code Playgroud)