twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
460 stars 178 forks source link

How to use hdmi speaker as output when using usb-c to hdmi adaptor? #636

Open MatthewVoyceGlobal opened 2 years ago

MatthewVoyceGlobal commented 2 years ago

Before filing an issue please check that the issue is not already addressed by the following:

If this is an issue with the QuickStart itself, file it here. If this is an issue with the SDK or how to do something with the SDK please use twilio-video-ios instead.

Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Description

Here is use case, when I use adaptor connect iphone/ipad to hdmi monitor (with speaker), I want to force the audio sound out from the hdmi speaker. The playing ring tong comes from the hdmi speaker, but as long as the video room initialed all the sound come from the ipad/iphone speaker, I guess there is some overwrite when the sdk audio track initialed, so I search the twilio video document and try to overwrite the audio output devices, but the document seems like un finished, I put code into the block(The following code is what I am using).

            TVIConnectOptions *connectOptions = [TVIConnectOptions optionsWithToken:self.videoAccessToken
                                                                              block:^(TVIConnectOptionsBuilder * _Nonnull builder) {
                                builder.audioTracks = self.localAudioTrack ? @[ self.localAudioTrack ] : @[ ];
                builder.videoTracks = self.localVideoTrack ? @[ self.localVideoTrack ] : @[ ];               
                builder.roomName = roomName;
            }];
            TVIDefaultAudioDevice * defaultDevice =  [TVIDefaultAudioDevice audioDevice];
            defaultDevice.block =^ {
                kTVIDefaultAVAudioSessionConfigurationBlock();
                AVAudioSession * session = [AVAudioSession sharedInstance];
                [session setActive:YES error:nil];

                [session setMode:AVAudioSessionModeVoiceChat error:nil];
                [session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
                [session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil];

            };
            dispatch_async(dispatch_get_main_queue(), ^{
                TwilioVideoSDK.audioDevice = defaultDevice;
                defaultDevice.block();
                _room = [TwilioVideoSDK connectWithOptions:connectOptions delegate:self];
                [self fetchConferenceInfo];
            });

And my question is 1 does twiliovideo sdk support change output device? 2 if question 1 is yes, how can I do that, any document or reference I can learn