尝试修复参数不生效的问题

This commit is contained in:
zher52 2021-10-11 17:49:05 +08:00
parent 25a7be1eef
commit ec0ea741a7
7 changed files with 22 additions and 13 deletions

View File

@ -9,32 +9,32 @@
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@class SGRecordOptions;
@interface SGRecordEncoder : NSObject
@property (nonatomic, readonly) NSString *path;
/**
SGRecordEncoder遍历构造器
@param path
@param cy
@param cx
@param options
@param ch
@param rate
@return SGRecordEncoder实例
*/
+ (SGRecordEncoder*)encoderForPath:(NSString*) path Height:(NSInteger) cy width:(NSInteger) cx channels: (int) ch samples:(Float64) rate;
+ (SGRecordEncoder*)encoderForPath:(NSString*) path Options:(SGRecordOptions*) options channels: (int) ch samples:(Float64) rate;
/**
@param path
@param cy
@param cx
@param options
@param ch
@param rate
@return SGRecordEncoder实例
*/
- (instancetype)initPath:(NSString*)path Height:(NSInteger)cy width:(NSInteger)cx channels: (int)ch samples:(Float64)rate;
- (instancetype)initPath:(NSString*)path Options:(SGRecordOptions*) options channels: (int)ch samples:(Float64)rate;
/**

View File

@ -15,11 +15,11 @@
@property (nonatomic, strong) AVAssetWriterInput *videoInput;//
@property (nonatomic, strong) AVAssetWriterInput *audioInput;//
@property (nonatomic, strong) NSString *path;//
@property (nonatomic, strong) SGRecordOptions * options;
@property (nonatomic, strong) SGRecordOptions *options;
@end
@implementation SGRecordEncoder
+ (SGRecordEncoder*)encoderForPath:(NSString*) path Options:(SGRecordOptions*) options channels: (int) ch samples:(Float64) rate{
+ (SGRecordEncoder*)encoderForPath:(NSString*) path Options: (SGRecordOptions *) options channels: (int) ch samples:(Float64) rate{
SGRecordEncoder* enc = [SGRecordEncoder alloc];
enc.options = options;
return [enc initPath:path channels:ch samples:rate];

View File

@ -561,7 +561,7 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice);
[self setAudioFormat:fmt];
NSString *videoName = [self getUploadFile_type:@"video" fileType:@"mp4"];
self.videoPath = [[self getVideoCachePath] stringByAppendingPathComponent:videoName];
self.recordEncoder = [SGRecordEncoder encoderForPath:self.videoPath Height:_cy width:_cx channels:_channels samples:_samplerate];
self.recordEncoder = [SGRecordEncoder encoderForPath:self.videoPath Options: self.options channels:_channels samples:_samplerate];
}
//
if (self.discont) {

View File

@ -3,6 +3,7 @@
//
#import <Foundation/Foundation.h>
#import <Cordova/CDVCommandDelegate.h>
@protocol CDVCommandDelegate;

View File

@ -3,7 +3,6 @@
//
#import <Cordova/CDVInvokedUrlCommand.h>
#import <Cordova/CDVCommandDelegate.h>
#import "SGRecordOptions.h"
@ -20,6 +19,7 @@
options.bitRate = [command argumentAtIndex:3 withDefault: @(options.height * options.width * 6)];
options.limit = [command argumentAtIndex:4 withDefault:@(3)];
options.duration = [command argumentAtIndex:5 withDefault:@(10)];
NSLog(@"width:%d - height:%d - frameRate:%d - bitRate:%d limit:%d dutation:%d",options.width,options.height,options.frameRate,options.bitRate,options.limit,options.duration);
return options;
}
@end

View File

@ -15,7 +15,6 @@
#import "SGRecordProgressView.h"
#import "UIButton+Convenience.h"
#import "SGRecordOptions.h"
#import "SGRecordOptions.h"
#import "SGMotionManager.h"
#define TIMER_INTERVAL 0.5 //

View File

@ -1,7 +1,16 @@
var exec = require('cordova/exec');
var argscheck = require('cordova/argscheck');
module.exports = {
capture(option, success, error) {
exec(success, error, 'CapturePlugin', 'capture', [option.width,option.height,option.frameRate,option.bitRate,option.limit,option.duration]);
var getValue = argscheck.getValue;
var width = getValue(option.width, 360);
var height = getValue(option.height, 640);
var frameRate = getValue(option.frameRate, 30);
var bitRate = getValue(option.bitRate, width * height * 6);
var limit = getValue(option.limit, 3);
var duration = getValue(option.duration, 10);
exec(success, error, 'CapturePlugin', 'capture', [width,height,frameRate,bitRate,limit,duration]);
}
};