我希望我的YouTubePlayer State更改视图控制器中的公共变量。YTPlayer代理功能和开关出现问题。这是我的变体…
var ytps = String!
这是youtube的状态函数。。。
func playerView(player: YTPlayerView!, didChangeToState state: YTPlayerState)
{
switch (state)
{
case YTPlayerState.Ended:
// handle ended state
print("Ended")
break;
case YTPlayerState.Paused:
// handle paused state
print("Paused")
break;
default:
break;
}
}
如何获取YTPlayerState.Endd或YTPlayerState.Paused的状态以将空字符串的值更改为"Ended/Paused"?
我想您可以用ytps = "Paused"
和ytps = "Ended"
替换print("Paused")
和print("Ended")
。完整示例:
var ytps = String()
func playerView(player: YTPlayerView!, didChangeToState state: YTPlayerState) {
switch state {
case YTPlayerState.Ended:
ytps = "Ended"
break
case YTPlayerState.Paused:
ytps = "Paused"
break
default:
break
}
}