• SEARCH
  • DOWNLOADS
  • MY ACCOUNT
  • Buy (0)
  • CONTACT
  • Free Trial
Wowza Logo
  • PRODUCTS
  • DEVELOPER
  • SOLUTIONS
  • PRICING
  • RESOURCES
  • SUPPORT
  • My Account
  • Buy (0)
  • SEARCH
  • Ask a question
  • Forums
    • Wowza ClearCaster Pro
    • Wowza Streaming Engine
    • Wowza Streaming Cloud
    • Wowza Player
    • Wowza GoCoder SDK
    • Wowza Developer Dojo
    • Topics
    • Questions
    • Articles
    • Users
    • Badges
  • Sign in
  • Community Home /
  • Wowza GoCoder SDK /
avatar image
Question by Francesco Galgani · Oct 22 at 12:57 PM · ios

Center CameraView inside the UIView

I wrote:

-(void*)getCameraView:(NSString*)param{
    
    __block UIView* result = nil;
    NSString* key = param;
    
    dispatch_sync(dispatch_get_main_queue(), ^{
        if (container == nil) {
            UIView *topView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
            container = [[UIView alloc] initWithFrame:topView.bounds];
            [container setBackgroundColor:(UIColor.blackColor)];
        }
        
        if (self.goCoder == nil) {
            // Register the GoCoder SDK license key
            NSError *goCoderLicensingError = [WowzaGoCoder registerLicenseKey:key];
            if (goCoderLicensingError != nil) {
                // Log license key registration failure
                com_codename1_io_Log_p___java_lang_String(CN1_THREAD_GET_STATE_PASS_ARG fromNSString(CN1_THREAD_GET_STATE_PASS_ARG [goCoderLicensingError localizedDescription]));
            } else {
                // Initialize the GoCoder SDK
                self.goCoder = [WowzaGoCoder sharedInstance];
            }
        }
        
        
        if (self.goCoder != nil) {
            // Associate the U/I view with the SDK camera preview
            self.goCoder.cameraView = container;
            
            // Start the camera preview
            [self.goCoder.cameraPreview startPreview];
            
            result = container;
        }
        
    });
    return result;
}

Note that I used:

[container setBackgroundColor:(UIColor.blackColor)];

to see the size of the container (the default color is white).

Result (the camera preview IS NOT CENTERED inside its black UIView):

Moreover, when I rotate the screen from portrait to landscape, I get:

Could you help me to fix my code?

Note that for me it's mandatory that I return a UIView with the camera preview (the reason is explained here:

https://stackoverflow.com/questions/58349108/from-ios-objective-c-code-and-android-java-code-to-a-codename-one-peercomponent

Thank you

portrait.jpg (50.0 kB)
landscape.jpg (17.4 kB)
Comment

People who like this

0 Show 0
10 |600 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

goCoderSDK sample doesn't work on iPad 4 iOS 10.3.3 9 Answers

fatal error: 'WowzaGoCoderSDK/WowzaGoCoderSDK.h' file not found 1 Answer

tvOS support 2 Answers

Landscape video with black bars if device is hold as portrait on streaming start 1 Answer

[iOS] Is there any way can achieve zoom in-out behavior on camera view when doing live streaming? 1 Answer

Hot Topics
  • Streaming Protocols
  • Wowza SDKs
  • AWS Hosting
  • Deployment Options
  • Load Balancing
  • Content Security
Product Sign-in
  • Wowza Streaming Cloud
  • Wowza Player
Under the Hood
  • Developer Tools
  • Wowza System Status
  • Test Players
  • Developer IDE
Partners
  • Partners Overview
  • Find a Reseller
  • Channel Partner Program
  • OEM Program
  • Wowza Reseller Portal
Company
  • About Us
  • Blog
  • News
  • Events
  • Careers
  • Customers
  • Contact Us
Stay Connected
Sign Up for Our Blog
Select a Language
  • English
    • English
    • Español
    • 日本語
    • 한국어
    • हिन्दी भाषा
    • 中文
    • русский язык

© 2005–2019 Wowza Media Systems, LLC. All rights reserved.   Terms | Privacy | Trademarks | Legal


Enterprise
Social Q&A

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Forums
  • Wowza ClearCaster Pro
  • Wowza Streaming Engine
  • Wowza Streaming Cloud
  • Wowza Player
  • Wowza GoCoder SDK
  • Wowza Developer Dojo
  • Explore
  • Topics
  • Questions
  • Articles
  • Users
  • Badges