标签:javascript flash youtube-api embedded-resource
好吧,我被卡住了,即使在关注了Google的文档并在Stackoverflow上阅读建议之后我也不知道出了什么问题.为什么我无法在网页中控制Youtube嵌入?
如果我使用< body>创建HTML文件存在:
<object id="o1" width="480" height="295">
<param name="movie"
value="http://www.youtube.com/v/qCTLCNmnlKU&hl=en_US&fs=1&enablejsapi=1&">
</param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed id="e1"
src="http://www.youtube.com/v/qCTLCNmnlKU&hl=en_US&fs=1&enablejsapi=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true" width="480" height="295">
</embed>
</object>
即使我试图这样做:
// I get an object. Yay.
document.getElementById('e1');
// This generates "...playVideo is not a function"
document.getElementById('e1').playVideo();
救命!我究竟做错了什么?谢谢.
解决方法:
好的,所以这是API页面上一小段文字的答案:http://code.google.com/apis/youtube/js_api_reference.html
“Note: To test any of these calls, you must have your file running on a webserver, as the Flash player restricts calls between local files and the internet.”
因此,为了让我继续在Mac笔记本电脑上进行开发,我做了以下工作:
>编辑我的/ etc / hosts文件以包含一个返回我的localhost的条目:
127.0.0.1 testhost.com
>编辑我的/etc/apache2/httpd.conf文件以添加指向我的开发目录的虚拟主机条目:
<VirtualHost *:80>
ServerName testhost.com
DocumentRoot /Users/amy/flashproj
<Directory /Users/amy/flashproj>
AllowOverride all
Options MultiViews Indexes FollowSymLinks
Allow from All
</Directory>
</VirtualHost>
>重启Apache:
sudo apachectl restart
>通过我的新虚拟服务器浏览回我自己的localhost:
http://testhost.com
瞧.这完全有效.我可以查询播放器的页面:
document.getElementById('e1'); // OK
document.getElementById('e1').playVideo(); // OK!
呼!没有onYouTubePlayerReady()也需要!
标签:javascript,flash,youtube-api,embedded-resource 来源: https://codeday.me/bug/20190730/1583308.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。