Stream availability checking¶
Since iOS SDK build 2.6.48 it is possible to check if a stream with a given name is available on a server for playback, like WebSDK function Stream.available().
To do this:
-
Create a separate Stream object with the stream name to check availability
Objective C code
Swift codeFPWCSApi2Session *session = [FPWCSApi2 getSessions][0]; FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init]; options.name = _remoteStreamName.text; options.display = _remoteDisplay; FPWCSApi2Stream *stream = [session createStream:options error:nil];
-
Call
FPWCSApi2Stream.available()
method with callback function to get availability status and reason if stream is not available
Objective C code
Swift code[stream available:^(BOOL available, NSString *info) { [self changeViewState:button enabled:YES]; if (available) { _remoteStreamStatus.text = @"AVAILABLE"; _remoteStreamStatus.textColor = [UIColor greenColor]; } else { _remoteStreamStatus.text = info; _remoteStreamStatus.textColor = [UIColor redColor]; } }];
... do { playStream = try session!.createStream(options) playStream?.available({ (available, info) in self.changeViewState(self.availableButton, true) if (available) { self.playStatus.text = "AVAILABLE" self.playStatus.textColor = .green } else { self.playStatus.text = info self.playStatus.textColor = .red } }) } catch { print(error) }