Hyperloop module LFLiveKit

199 views Asked by At

I have an issue with native issues in my hyperloop module for LFLiveKit, looking for some advice and help.

I only see a red screen showing. I also get the alerts for the permissions.

Here is my code:

var UIScreen = require('UIKit/UIScreen'),
    UIViewController = require('UIKit/UIViewController'),
    UIView = require('UIKit/UIView'),
    UIColor = require('UIKit/UIColor'),
    CGPointMake = require('CoreGraphics').CGPointMake,
    CGRectMake = require('CoreGraphics').CGRectMake,
    NSBundle = require('Foundation/NSBundle'),
    NSURL = require('Foundation/NSURL'),
    NSData = require('Foundation/NSData'),
    AVPlayer = require('AVFoundation/AVPlayer'),
    AVPlayerLayer = require('AVFoundation/AVPlayerLayer'),
    UIColor = require('UIKit/UIColor'),
    NSString = require("Foundation/NSString"),
    UIImage = require('UIKit/UIImage'),
    UIImageView = require('UIKit/UIImageView'),
    LFLiveKit = require('LFLiveKit/LFLiveKit'),
    LFLiveAudioConfiguration = require("LFLiveKit/LFLiveAudioConfiguration"),
    LFLiveVideoConfiguration = require("LFLiveKit/LFLiveVideoConfiguration"),
    LFLiveSession = require("LFLiveKit/LFLiveSession"),
    LFLiveStreamInfo = require("LFLiveKit/LFLiveStreamInfo"),
    LFLiveVideoQuality = require("LFLiveKit").LFLiveVideoQuality,
    AVCaptureDevice = require("AVFoundation/AVCaptureDevice"),
    AVMediaTypeVideo = require("AVFoundation").AVMediaTypeVideo,
    AVMediaTypeAudio = require("AVFoundation").AVMediaTypeAudio,
    TiApp = require('Titanium/TiApp');
1

There are 1 answers

1
Julien Gattegno On

var config = LFLiveAudioConfiguration.defaultConfiguration();

var audioConfiguration = LFLiveAudioConfiguration.defaultConfiguration();
var videoConfiguration = LFLiveVideoConfiguration.defaultConfiguration();
var viewController = UIViewController.alloc().init();

var session = LFLiveSession.alloc().init();
session.audioConfiguration = audioConfiguration;
session.videoConfiguration = videoConfiguration;
var bounds = UIScreen.mainScreen.bounds;
var frame = CGRectMake(0, 0, bounds.size.width, bounds.size.height);

function requestAccessForVideo() {
    Ti.API.info("requestAccessForVideo");
    var status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo);
    Ti.API.info(status);

}

Ti.Media.requestAudioRecorderPermissions(function(e) { 
    if (e.success) {
        requestAccessForAudio();
         alert('You dont denied permission');
    } else {
        alert('You denied permission');
    }
});

function requestAccessForAudio() {
    Ti.API.info("requestAccessForAudio");
    var status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeAudio);
    Ti.API.info(status);
    startLive();
}

requestAccessForVideo();

viewController.view.frame = frame;
viewController.view.backgroundColor = UIColor.redColor;
session.preView = viewController.view;
function startLive() {
    session.running = true;
    streamInfo = new LFLiveStreamInfo();
    streamInfo.url = "rtmp://live.hkstv.hk.lxdns.com:1935/live/stream153";
    session.startLive(streamInfo);
     Ti.API.info("STARTED");
    // TiApp.app().showModalController(viewController, true);

}

$.index.add(viewController.view);
$.index.open();