How add Kaltura sdk Player in iOS xamarin form

I am working in Kaltura sdk to stream my videos.how can I integrate kaltura to xamarin form cross platform, could you help me with this situation?

Hi @pruebas_testa,

Xamarin doesn’t have OOB swift binding, but this can be overcome by exporting us statically via the object bridge.
We haven’t tested it and haven’t intended to support this so we’re not certain it will work but you can give it a try.
Have a look at this guide:
https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/

There’s also this article which explains how to create a binding for Swift in Xamarin:

Good luck,

Hi @jess

I already implemented the swift binding but it returns the following error when I am integrating the binding to the xamarin ios project

System.Exception: Could not create an native instance of the type ‘MediaSource’: the native class hasn’t been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
at Foundation.NSObject.InitializeObject (System.Boolean alloced)

could you give me a hand with this.

hey @pruebas_testa,

Please make sure to use “PKMediaSource” not “MediaSource” with our latest version.

Best,
Eliza

Hey @elizas,

I am using the binding the lastes versión, the source is PKMediaSource but when the binding is done the result is as follows.

[Protocol]
    [Register("MediaSource", true)]
    public class MediaSource : NSObject, IMediaSource, INativeObject, IDisposable
    {
        [CompilerGenerated]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        [Export("init")]
        public MediaSource();
        [CompilerGenerated]
        [Export("initWithId:")]
        public MediaSource(string id);
        [CompilerGenerated]
        [DesignatedInitializer]
        [Export("initWithJson:")]
        public MediaSource(NSObject json);
        [CompilerGenerated]
        [DesignatedInitializer]
        [Export("init:contentUrl:mimeType:drmData:mediaFormat:")]
        public MediaSource(string id, NSUrl contentUrl, string mimeType, DRMParams[] drmData, MediaFormat mediaFormat);
        [CompilerGenerated]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        protected MediaSource(NSObjectFlag t);
        [CompilerGenerated]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        protected internal MediaSource(IntPtr handle);

        public override IntPtr ClassHandle { get; }
        [CompilerGenerated]
        public virtual NSUrl ContentUrl { get; set; }
        [CompilerGenerated]
        public virtual string Description { get; }
        [CompilerGenerated]
        public virtual DRMParams[] DrmData { get; set; }
        [CompilerGenerated]
        public virtual string FileExt { get; }
        [CompilerGenerated]
        public virtual string Id { get; set; }
        [CompilerGenerated]
        public virtual MediaFormat MediaFormat { get; set; }
        [CompilerGenerated]
        public virtual string MimeType { get; set; }
    }

Hey,

Can you share some sample that demonstrates the issue via Github and I will try to help you.
When uploading the sample please let us know what is the issue and what are the steps to reproduce.

Thanks,

Eliza

cc @oren_melamed

@elizas thanks for your help, I share an example of the problem I have

project which has the binding for Swift frameworks to be able to use it in xamarin forms

xamarin form project, which uses the previously compiled SharpieSDK dll

in the project sdkIOSBinding a class was created with the name KalturaViewRenderer but when calling the method DoPublish () exactly the line

var entry = new MediaEntry (“test”, null, 5000),

always returns the error
System.Exception: Could not create an native instance

Thanks.

@elizas on the other hand in android I have an issue which only happens in real device , which is reported in the following link

the java binding for xamarin form is this

when I add the BindingJar dll to the xamarin form android project.

in the OnElementChanged () method
when I execute the next line of code
player.Prepare (mediaConfig);

it returns me
{Java.Lang.NoSuchMethodError: No virtual method addListener(Lcom/google/android/exoplayer2/ExoPlayer$EventListener;)V in class Lcom/google/android/exoplayer2/SimpleExoPlayer; or its super classes (declaration of ‘com.google.android.exoplayer2.SimpleExoPlayer’ appears in /data/app/App9.Android-1/base.apk)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069]

Thanks.

please replace MediaEntry with PKMediaEntry

@vadim.kononov if you can visualize in the ios binding code, when swift code converting to code c# this PKMediaEntry is renamed with MediaEntry, in a few words it is the same

hi, @pruebas_testa
A new version is available, that should fix your issue


Best regards, Vadim

best information great thank u

Hi @vadim.kononov thanks for the feedback,

but I updated the version how you mention it and apparently it shows me a new error when compiling the cocopod, I attach the error in a text file.

Thanks.

hi, @pruebas_testa
The error you are observing during compilation relates to swift version. I don’t know exactly how xamarin works with pods, but you should verify that you are compiling our sdk with swift 4 compiler
Vadim

hi @vadim.kononov

finally I was able to compile the pods but again the issue of the native instance is returning me

{System.Exception: Could not create an native instance of the type ‘SharpieSDK.MediaEntry’: the native class hasn’t been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
at Foundation.NSObject.InitializeObject (System.Boolean alloced) [0x0003a] in //xamarin-macios/src/Foundation/NSObject2.cs:182
at Foundation.NSObject…ctor (Foundation.NSObjectFlag x) [0x0000d] in //source/xamarin-macios/src/Foundation/NSObject2.cs:117
at SharpieSDK.MediaEntry…ctor (System.String id, SharpieSDK.MediaSource[] sources, System.Double duration) [0x00000] in \SharpieSDK\obj\Debug\ios\SharpieSDK\MediaEntry.g.cs:187
at App8.iOS.OpenTokViewRenderer.DoPublish () [0x00002] in }

thanks for the feedback but I finally decided to use the native player of each platform.