- (voID)embedYouTube:(Nsstring *)urlString frame:(CGRect)frame{Nsstring *HTMLString = [Nsstring stringWithFormat:@"<HTML><head><Meta name = \"vIEwport\" content = \"initial-scale = 1.0,user-scalable = yes,wIDth = 320\"/></head><body style=\"background:#00;margin-top:0px;margin-left:0px\"><div><object wIDth=\"320\" height=\"180\"><param name=\"movIE\" value=\"http://www.youtube.com/v/%@&f=gdata_vIDeos&c=ytAPI-my-clIEntID&d=nGF83uyVrg8eD4rfEkk22mDol3qUImVMV6ramM\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/%@&f=gdata_vIDeos&c=ytAPI-my-clIEntID&d=nGF83uyVrg8eD4rfEkk22mDol3qUImVMV6ramM\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" wIDth=\"320\" height=\"180\"></embed></object></div></body></HTML>",urlString,urlString];UIWebVIEw *vIDeoVIEw = [[UIWebVIEw alloc] initWithFrame:frame];[vIDeoVIEw loadHTMLString:HTMLString baseURL:nil];[self.vIEw addSubvIEw:vIDeoVIEw];[vIDeoVIEw release];}
它像魅力一样,但我想要一个不同的行为.现在,视频的缩略图出现在网络视图中(很棒!),但是当我点击播放图标时,它将全屏打开.我需要在同一个窗口中完成播放,因为我需要显示更多的东西.
有什么线索呢? Thansk提前
解决方法 如果任何人仍然面临这个问题,下面是我看到的最好的解决方案.奇迹般有效.self.webVIEw = [[UIWebVIEw alloc] initWithFrame:CGRectMake(10,10,300,200)]; [self.webVIEw setAllowsInlinemediaplayback:YES]; [self.webVIEw setmediaplaybackRequiresUserAction:NO]; [self.vIEw addSubvIEw:self.webVIEw]; Nsstring* embedHTML = [Nsstring stringWithFormat:@"\ <HTML>\ <body style='margin:0px;padding:0px;'>\ <script type='text/JavaScript' src='http://www.youtube.com/iframe_API'></script>\ <script type='text/JavaScript'>\ function onYouTubeiframeAPIReady()\ {\ ytplayer=new YT.Player('playerID',{events:{onReady:onPlayerReady}})\ }\ function onPlayerReady(a)\ { \ a.target.playVIDeo(); \ }\ </script>\ <iframe ID='playerID' type='text/HTML' wIDth='%d' height='%d' src='http://www.youtube.com/embed/%@?enableJsAPI=1&rel=0&playsinline=1&autoplay=1' frameborder='0'>\ </body>\ </HTML>",200,@"JW5meKfy3fY"]; [self.webVIEw loadHTMLString:embedHTML baseURL:[[NSBundle mainBundle] resourceURL]];
资料来源:https://code.google.com/p/gdata-issues/issues/detail?id=5204
总结以上是内存溢出为你收集整理的如何在YouTube上嵌入YouTube视频,并直接在UIWebview上播放,无需全屏全部内容,希望文章能够帮你解决如何在YouTube上嵌入YouTube视频,并直接在UIWebview上播放,无需全屏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)