Hi,
I’m currently trying to use the TwitchKit v2.0.1 for user iOS application, on a video stream originated from the twitch streaming service integrated into PS4. I followed all steps on the README.md guide, including all frameworks and using the function presentStreamForChannelNamed passing the name of the channel as specified.
I noticed that if I pass the value “TKStreamPresentationModeUseTwitchAppIfInstalled” as mode parameter it launches Twitch App and starts the video playback as expected while if I try to embed the video on my app using the value “TKStreamPresentationModeRemainInApp” nothing happens on screen, plus I dont receive any notification. I tried to disable visibility on user UIView areas that could be occluding the video without any result.
Appart from that I’m actually surprised that there’s apparently no placement nor size parameters on the TwitchKit interface for embedding the video stream within the user window like you can do with the UIWebView. Is there any way to achieve it?
Thank you very much.
When TwitchKit v2.0.1’s presentStreamForChannelNamed: method is invoked with the TKStreamPresentationModeRemainInApp option it will attempt to present a modal view controller with a player for the requested channel. The current logic attempts to present the view from either the main window’s root view controller or that view controller’s presented view. If both of those view controllers currently have presented views, nothing will be displayed. Can you inspect your view controller hierarchy and see if that’s your issue?
Hi maciform.
I tried both calling presentStreamForChannelNamed after setting the view hierarchy I use on the application and also when there’s no view set already (just on “application” function in application delegate class) with no result.
I tried also a even easier test making a new project in Xcode using single view application template, and calling presentStreamForChannelNamed on the viewDidLoad function inside ViewController.m file, with no result aswell.
Anyway I noticed in your answer (modal view controller with a player) that I wouldn’t be able really to embed the viewer in my application the way I look for, that is, overprinting some game interface on the video in order to make it interactive (interactive in gameplay sense, making game actions related to the content of the video).
While trying to achieve it in a different way I noticed that embedding the UIWebView with the parameters “mediaPlaybackRequiresUserAction = NO” and “allowsInlineMediaPlayback = YES” and opening the URL “http://twitch.tv/{USER_ID}/hls” enables me to draw custom user interface with responsive control on top of the video the way I wanted. Is there any practical difference compared to the presentStreamForChannelNamed function?
I wanted to ask you also if there’s any legal/ToS problem about placing custom user interface in front of the video playback (for instance, it’s ok to have items unintentionally masking out part of the commercials when they appear).
Thank you very much.
Regarding your continued presentation problems, the presentStreamForChannelNamed method actually makes explicit reference to the UIApplication’s keyWindow property, so verify that it is set before you invoke it. Depending on your setup, you may need to delay invocation. Then you still need to ensure that either the rootViewController or its presented view controller are able to present a modal.
If modal presentation of a player isn’t the behavior you desire then you can definitely just employ a UIWebView. We recommended using the twitch.tv/:channel/embed endpoint rather than the deprecated twitch.tv/:channel/hls. That’s all that presentStreamForChannelName does when TKStreamPresentationModeRemainInApp is specified.
It should be fine to overlay your own playback controls, so long as they’re not used to circumvent ad playback.
Cool, thank you.
It would be nice to have interface on TwitchKit to control UIWebView parameters like allowsInlineMediaPlayback, the frame initialization or the view parent explicitly.