我正在使用Kevin Nilson在GitHub上托管的CastVideos-ios示例。
首先,如果这听起来有些奇怪或者没有必要,我很抱歉,但我有这个问题需要解决。
我想要做的是拒绝访问/连接,如果某个用户已经在电视上看到/投放媒体。
就目前而言,我未来的目标是创建一个管理众多用户的队列,让我解释一下:
在家中,有一台电视和一台Chromecast,家庭/用户共享同一个网络并希望在同一台电视上播放,我如何在不断开活动用户的情况下管理它?
从设备(iPhone),至少可以发出警告说“你即将断开某人的iPhone” - 是或否。
不知道我是否必须在发件人中实现此功能,如下面所示或使用JavaScript接收器。
感谢您的时间。
(更新)
- (void)connectToDevice:(GCKDevice *)device {
NSLog(@"Device address: %@:%d", device.ipAddress, (unsigned int) device.servicePort);
self.selectedDevice = device;
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSString *appIdentifier = [info objectForKey:@"CFBundleIdentifier"];
self.deviceManager =
[[GCKDeviceManager alloc] initWithDevice:self.selectedDevice clientPackageName:appIdentifier];
self.deviceManager.delegate = self;
// check if someone is already connected or playing media ...
// the problem here is than I only can disconnect my own device
if (_streamDuration > 0) { // if the current stream duration is greater than 0 ...
// than disconnect
[self.deviceManager leaveApplication];
[self.deviceManager disconnect];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"You are about to disconnect iPhone of Someone" delegate:self cancelButtonTitle:@"Not" otherButtonTitles:@"Ok", nil];
[alert show];
//reset the button status ...
// connect
} else {
[self.deviceManager connect];
}
// Start animating the cast connect images.
UIButton *chromecastButton = (UIButton *)self.chromecastBarButton.customView;
chromecastButton.tintColor = [UIColor whiteColor];
chromecastButton.imageView.animationImages =
@[ [UIImage imageNamed:@"icon_cast_on0.png"], [UIImage imageNamed:@"icon_cast_on1.png"],
[UIImage imageNamed:@"icon_cast_on2.png"], [UIImage imageNamed:@"icon_cast_on1.png"] ];
chromecastButton.imageView.animationDuration = 2;
[chromecastButton.imageView startAnimating];
}