KSYLive_iOS icon indicating copy to clipboard operation
KSYLive_iOS copied to clipboard

RTMP broadcasting when the app goes in background

Open jsfan3 opened this issue 4 years ago • 2 comments

Thank you so much for your great library. I tried to use it to make a live streaming: it works properly.

The moment the app goes into the background, however, the RTMP stream stops. What can I do to make the streaming continue even when the app goes in the background? When recording events, it is essential that the streaming is not accidentally interrupted by a phone call or another app.

Thank you for your support.

This is my code:

#import "net_informaticalibera_test_rmtpclient_RMTPBroadcastNativeImpl.h"
#import <GPUImage/GPUImage.h>
#import <libksygpulive/KSYGPUStreamerKit.h>
#import "CodenameOne_GLViewController.h"
#import "cn1_globals.h"
#import "com_codename1_io_Log.h"
#import "com_codename1_ui_CN.h"

@implementation net_informaticalibera_test_rmtpclient_RMTPBroadcastNativeImpl

KSYGPUStreamerKit* kit = nil;
NSURL* url = nil;
UIView* myView = nil;

-(void)startBroadcast{
    dispatch_sync(dispatch_get_main_queue(), ^{
        NSLog(@"Value of url = %@", url.absoluteString);
        [kit.streamerBase startStream:url];
    });
}

-(void)switchCamera{
    dispatch_sync(dispatch_get_main_queue(), ^{
        [kit switchCamera];
    });
}

-(void*)getCameraPreview:(NSString*)param{
    dispatch_sync(dispatch_get_main_queue(), ^{
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
        
        url = [[NSURL alloc] initWithString:param];
        CGSize size = [UIScreen mainScreen].bounds.size;
        myView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height)];
        kit = [[KSYGPUStreamerKit alloc] initWithDefaultCfg];
        [kit startPreview:myView];
    });
    return myView;
}

-(void)stopBroadcast{
    dispatch_sync(dispatch_get_main_queue(), ^{
        [kit.streamerBase stopStream];
    });
}

-(BOOL)isSupported{
    return YES;
}

@end

jsfan3 avatar Jul 18 '20 09:07 jsfan3

hello, have you found the solution for this? I just met this issue :D Tks

ducbm-belive avatar May 11 '21 08:05 ducbm-belive

@ducbm-belive No, I didn't find a solution

jsfan3 avatar May 11 '21 12:05 jsfan3