Video Streaming, when launches only shows the front camera and not the back camera, how do I change this, I use the instructions in the Video Streamin

I followed the instructions exactly how they are posted on the backendless website with the develop a Video Audio app but when when you press the record button it only shows the front camera and not the back camera. How do I fix this.
THanks

The MediaService method
-(MediaPublisher *)publishStream:(NSString *)name tube:(NSString *)tube options:(MediaPublishOptions *)options responder:(id <IMediaStreamerDelegate>)delegate;
returns MediaPublisher instance, and it has the public method
-(void)switchCameras;

Here is the current code that I have in the app,

  • (void)onRecordBtn:(id)sender

{

MediaPublishOptions *options = [MediaPublishOptions recordStream:self.preview];

_publisher =[backendless.mediaService publishStream: STREAM_NAME tube:VIDEO_TUBE options:options responder:self];

}
I am a newbie so I am sort of confused with the code you sent, would the code above be additional code or replace the code I have above. Thank you for all your help.

The “_publisher” object you received as a result of calling the “publishStream” method has method “switchCameras”. So what you need to do is to call switchCameras using the _publisher instance.

You can set a back camera during publisher initialization:

  • (void)onRecordBtn:(id)sender
    {

    MediaPublishOptions *options = [MediaPublishOptions recordStream:self.preview];

    _publisher = [backendless.mediaService publishStream: STREAM_NAME tube:VIDEO_TUBE options:options responder:self];

[_publisher switchCameras];

}

or you can add a button for camera switching:

  • (void)onSwitchCamerasBtn:(id)sender
    {

[_publisher switchCameras];

}

I am still confused and my ? has not been answered, does the new code for whichVyacheslav Vdovichenkosent replace the original code for which I pasted above or does it get added in the Viewcontroller.m area. Thanks

Tom, I believe your question has been answered. You asked how to switch cameras and Vyacheslav posted complete code showing the sequences of calls to do that. See the response marked as “Best Response”. If you compare the code you posted with the code in that response, you will see the difference (i.e. the addition of the switchCameras call).

Regards,
Mark

Tom,

you can download backendless demo samples from our github repo -

and investigate VideoService target - there are all functions you can use with publisher and player.

Thank you so much. I am still learning but that helped a great deal and I do see the difference. Thank you. I am testing it now. Once again thank you for all your help and quick response. Excellent CS.

In the new code, code as follows, how does one set the code so when viewcontroller is used it only shows the back camera only with no camera switch.

-(IBAction)publishControl:(id)sender

{

NSLog(@"publishControl: -> backendless.mediaService: %@ [%@]", backendless.mediaService, [Types classByName:@"MediaService"]);



MediaPublishOptions *options = (_switchView.on)?[MediaPublishOptions liveStream:self.preview]:[MediaPublishOptions liveStream:self.preview];

//options.videoBitrate = 2000;

//options.content = ONLY_AUDIO;

_publisher =[backendless.mediaService publishStream:_streamName tube:VIDEO_TUBE options:options responder:self];



self.btnPublish.hidden = YES;

self.btnPlayback.hidden = YES;

self.textField.hidden = YES;

_switchView.hidden = YES;

_lable.hidden = YES;

[_netActivity startAnimating];

}