1

我在 LFLiveKit 的超循环模块中遇到了原生问题,正在寻找一些建议和帮助。

我只看到一个红屏显示。我还收到有关权限的警报。

这是我的代码:

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');
4

1 回答 1

0

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();
于 2017-08-05T10:50:27.357 回答