0

i use medialibdemos3x in my app & my problem is when i stream video in landscape mode it shows like this Image:
Image

& here is my code:

@interface ViewControllerPublish () <MPIMediaStreamEvent>{    
MemoryTicker            *memoryTicker;
RTMPClient              *socket;
BroadcastStreamClient   *upstream;

MPVideoResolution       resolution;
AVCaptureVideoOrientation orientation;
UIActivityIndicatorView *netActivity;
UIDeviceOrientation deviceOrientation;}

-(void)viewDidLoad {
//[DebLog setIsActive:YES];
[super viewDidLoad];

[self initNetActivity];


memoryTicker = [[MemoryTicker alloc] initWithResponder:self andMethod:@selector(sizeMemory:)];
memoryTicker.asNumber = YES;

socket = nil;
upstream = nil;}

-(void)doConnect {

resolution = RESOLUTION_CIF;  
#if upstream = [[BroadcastStreamClient alloc] init:host resolution:resolution];
//upstream = [[BroadcastStreamClient alloc] initOnlyAudio:hostTextField.text];
//upstream = [[BroadcastStreamClient alloc] initOnlyVideo:hostTextField.text resolution:resolution];

 #else

if (!socket) {
    socket = [[RTMPClient alloc] init:hostTextField.text];
    if (!socket) {
        [self showAlert:@"Connection has not be created"];
        return;}

    [socket spawnSocketThread];}

upstream = [[BroadcastStreamClient alloc] initWithClient:socket resolution:resolution];

#endif

upstream.delegate = self;

upstream.videoCodecId = MP_VIDEO_CODEC_H264;

upstream.audioCodecId = MP_AUDIO_CODEC_AAC;

& here is my Orientation code:

deviceOrientation =
[[UIDevice currentDevice] orientation];
if ( deviceOrientation == UIDeviceOrientationLandscapeLeft )
    orientation  = AVCaptureVideoOrientationLandscapeRight;

else if ( deviceOrientation == UIDeviceOrientationLandscapeRight )
    orientation  = AVCaptureVideoOrientationLandscapeLeft;

else  orientation = AVCaptureVideoOrientationPortrait;

[upstream setVideoOrientation:orientation];

[upstream stream:stream publishType:PUBLISH_LIVE];
//[upstream stream:streamTextField.text orientation:orientation publishType:PUBLISH_RECORD];
//[upstream stream:streamTextField.text orientation:orientation publishType:PUBLISH_APPEND];

btnConnect.title = @"Disconnect";

[netActivity startAnimating];}

is there a way to solve this problem? thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

As per apple guideline, you can't forcefully change application's orientation for different viewController when using navigation controller. you can set or allow orientation for particular viewcontroller but user have to rotate device.

refer this link for that how to allow different orientations. This have good question and many good answers. click here

Hope this will help. :)

Community
  • 1
  • 1
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75