我知道要停用相关视频,我们需要在YouTube网址末尾添加?rel=0
。我的问题是如何在Swift中做到这一点?
我无法找到一种方法来编辑HTML / JavaScript / Objective C文件以使其正常工作。
我不确定如何使用loadWithVideoId
传递参数,因为它始终无法编译。
任何出路?
PS:我正在开发一款播放YouTube视频的iOS应用。我正在尝试禁用相关视频,我使用的是YouTube-iOS-helper
。
答案 0 :(得分:4)
在您的playerVars词典中将 <Spinner
android:id="@+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dropDownVerticalOffset="@dimen/dropDownVerticalOffset" />
(相关)键设置为false(rel
):
0
然后按正常情况调用let playerVars = [ "rel" : 0 ]
:
loadWithVideoId
答案 1 :(得分:1)
按照它说的那样检查official documentation,&#34;没有针对Swift&#34;的开发。
Xcode 6.1.1 for iOS 8.1,这个项目不会编译。
开发人员仍在等待新的更新。然后,您可以使用此第三方库https://github.com/gilesvangruisen/Swift-YouTube-Player/
或者您可以等待Google或Apple的新更新。
答案 2 :(得分:0)
我相信你需要将它添加到playerVars。为了简化我的Swift项目中的内容,我将其直接添加到YTPlayerView.m loadWithVideoId函数中,因此它将是:
- (BOOL)loadWithVideoId:(NSString *)videoId playerVars:(NSDictionary *)playerVars {
if (!playerVars) {
playerVars = @{@"showinfo": @0}
}
NSDictionary *playerParams = @{ @"videoId" : videoId, @"playerVars" : playerVars };
return [self loadWithPlayerParams:playerParams];
}