Broadcast Extension with ReplayKit Xamarin iOS not displaying device screen

180 Views Asked by At

I created a Xamarin forms project and added Broadcast Upload Extension and Extension UI and reference them into IOS Project also I followed the instructions in the doc here

https://learn.microsoft.com/en-us/xamarin/ios/platform/extensions#container-app-project-requirements

I uses agora for screen sharing but the result is the device share the camera instead of it's screen

I followed this sample https://github.com/DreamTeamMobile/Xamarin.Agora.Samples/tree/master/ScreenSharing

and added a Dependency service Interface to invoke it from Xamarin forms all is working expect device share it's camera not it's screen

public class AgoraServiceImplementation : IAgoraService
{

    private void JoiningCompleted(Foundation.NSString arg1, nuint arg2, nint arg3)
    {
        _myId = arg2;
        _agoraEngine.SetEnableSpeakerphone(true);
        JoinChannelSuccess((uint)_myId);

        var bundle = NSBundle.MainBundle.GetUrlForResource("ScreenSharingIOSExtension", "appex", "PlugIns");


        var frame = new CGRect(100, 100, 60, 60);
        var broadcastPicker = new RPSystemBroadcastPickerView(frame);
        var bundle2 = new NSBundle(bundle);
        broadcastPicker.PreferredExtension = bundle2.BundleIdentifier;

        var vc = Platform.GetCurrentUIViewController();
        vc.Add(broadcastPicker);

    }

    public void StartShareScreen(string sessionId, string agoraAPI, string token, VideoAgoraProfile profile = VideoAgoraProfile.Portrait360P, bool swapWidthAndHeight = false, bool webSdkInteroperability = false)
    {
        _agoraDelegate = new AgoraRtcDelegate(this);
        _agoraEngine = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate(agoraAPI, _agoraDelegate);
        _agoraEngine.EnableWebSdkInteroperability(webSdkInteroperability);
        _agoraEngine.SetChannelProfile(ChannelProfile.LiveBroadcasting);
        _agoraEngine.SetClientRole(ClientRole.Broadcaster);
        //
        _agoraEngine.EnableVideo();

        if (!string.IsNullOrEmpty(AgoraSettings.Current.EncryptionPhrase))
        {
            _agoraEngine.SetEncryptionMode(AgoraSettings.Current.EncryptionType.GetModeString());
            _agoraEngine.SetEncryptionSecret(helper.AgoraSettings.Current.EncryptionPhrase);
        }
        _agoraEngine.StartPreview();
        Join();
    }


    private async void Join()
    {
        var token = await AgoraTokenService.GetRtcToken(helper.AgoraSettings.Current.RoomName);
        if (string.IsNullOrEmpty(token))
        {
            //smth went wrong
        }
        else
        {
            _agoraEngine.JoinChannelByToken(token, AgoraSettings.Current.RoomName, null, 0, JoiningCompleted);
        }
    }
}

any help ?

0

There are 0 best solutions below