I have built a simple Xamarin iOS app to subscribe (no publishing) to a single stream and display it in my primary view. The app will connect to a screen capturing stream from a desktop application that will be publishing the stream.
My Setup
Windows VS paired to a remote Mac, running a simulator on my local windows environment.
Using Xamarin.OpenTok.iOS (SDK v2.17.1) Nuget package in project.
My project is not a Xamarin Forms cross-platform application, but solely an iOS application.
OpenTok session and tokens generated in project management portal. I have attempted both "Relay" and "Routed" with the same results. I have been creating tokens with a 7 day expiration.
In developing the implementation of the OpenTok SDK into my app, I have followed the project found here
The Issue
I am creating a new session passing in my newly generated API Key and Session Id and then Connecting with my subscriber token.
_session = new OTSession(_apiKey, _sessionId, null);
...
_session.ConnectWithToken(_userToken, out error);
I am also subscribing to relevant Session events (ConnectionDestroyed, DidConnect, StreamCreated, StreamDestroyed, DidFailWithError).
After starting this connection I am given the following output and none of the events I am subscribed to are invoked.
Output Log - StackOverflow would not let me paste the log here
I am also seeing an attempted connection to the Session in the OpenTok Inspector.
I am aware of this ticket and have confirmed it is not an expired token. I am pretty confident that this null reference is coming from the OpenTok SDK source code and not my code but cannot tell what it is. The error will completely freeze my app as the looping does not stop. Any help and guidance would be appreciated. So the questions are:
What is causing this error and how can I fix it? Am I missing an initialization step?
Is the iOS Simulator the real issue?
Thanks
a simple Xamarin iOS app to subscribe (no publishing) to a single stream and display it in my primary view. The app will connect to a screen capturing stream from a desktop application that will be publishing the stream
This is possible to implement with Xamarin Vonage Video API SDK. I will try to explain that as detailed as possible, feel free to skip ahead.
You started correctly with the Xamarin samples.
In fact, there are only 2 changes you need to do to achieve your goal with Xamarin.iOS app (not Xamarin.Forms, will get to that later):
OpentokTestConstants.cs
( here ) filePublish()
in the OpentokStreamingService
so that the app only subscribes to video streams in the session and does not publish camera stream Here is a screenshot running the sample app with these changes in iOS simulator and viewing a stream published from the web (I used the "The OpenTok Playground" tool for that)
Now, regarding Xamarin.Forms.
There is no sample for Xamarin.Forms, unfortunately. If you can share a sample app (without ApiKey/SessionId please) I'd be glad to look at it.
Generally, a logic for video calls on Xamarin.Forms is:
OpentokStreamingService
that is implemented in iOS/Android samples ( docs on how you do that in Xamarin.Forms ) _opentokService.SetStreamContainer(NativeView, false);
where NativeView is a native (Xamarin.iOS/Xamarin.Android) view (not Xamarin.Forms view). You can get that reference in the renderer's ElementChanged
method.
This doc from Xamarin covers that well .
After the selected line, Control
will have a native view reference that you just need to pass to OpentokStreamingService.
That will get you a scenario working in Xamarin.Forms. I hope that this answer helps!
PS: Logging with Vonage Video API Xamarin SDK on iOS
There is a better way to get logs for diagnostics purposes with iOS SDK. A call like that before any OpenTok SDK calls would give you a very detailed log of what's going on:
OpenTok.OpenTokExtraLogging.EnableOpenTokLoggingToConsole();
It will look like this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.