Skip to content

Commit 29aa040

Browse files
author
敛心
committed
暂时去除WebView组件
1 parent c503b9d commit 29aa040

17 files changed

Lines changed: 819 additions & 1519 deletions

IOS/SDK/LuaViewSDK.xcodeproj/project.pbxproj

Lines changed: 76 additions & 26 deletions
Large diffs are not rendered by default.

IOS/SDK/LuaViewSDK/Classes/LuaViewCore.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#import "LVPagerIndicator.h"
3232
#import "LVLoadingIndicator.h"
3333
#import "LVImage.h"
34-
#import "LVWebView.h"
34+
//#import "LVWebView.h"
3535
#import "LVLabel.h"
3636
#import "LVBaseView.h"
3737
#import "LVTransform3D.h"
@@ -249,7 +249,7 @@ -(void) registeLibs{
249249
[LVButton class],
250250
[LVImage class],
251251
[LVBitmap class],
252-
[LVWebView class],
252+
// [LVWebView class],
253253
[LVLabel class],
254254
[LVScrollView class],
255255
[LVCollectionView class],

IOS/SDK/LuaViewSDK/Classes/lvsdk/LVAudioPlayer.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ @interface LVAudioPlayer ()<AVAudioPlayerDelegate>
1616
@property(nonatomic,assign) BOOL playing;
1717
@property (nonatomic, copy) NSString *fileName;
1818

19+
@property (nonatomic, assign) CGFloat volume;
20+
1921
@end
2022

2123
@implementation LVAudioPlayer{
@@ -42,6 +44,7 @@ -(id) init:(lua_State*) L{
4244
self = [super init];
4345
if( self ){
4446
self.lv_luaviewCore = LV_LUASTATE_VIEW(L);
47+
_volume = -1;
4548
}
4649
return self;
4750
}
@@ -56,6 +59,8 @@ -(void) setPlayFileName0:(NSString*) fileName bundle:(LVBundle*) bundle{
5659
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];//使用本地URL创建
5760
audioPlayer.delegate = self;
5861

62+
[self setVolume:_volume];
63+
5964
if( error ) {
6065
NSLog(@"[LuaView][error]%@",error);
6166
}else{
@@ -89,6 +94,7 @@ -(void) setPlayFileName:(NSString*) fileName bundle:(LVBundle*) bundle{
8994
-(void) play {
9095
if (!self.playing){
9196
[audioPlayer play];
97+
[self setVolume:0.5];
9298
self.playing = YES;
9399
}
94100
}
@@ -98,6 +104,16 @@ -(void) stop {
98104
self.playing = NO;
99105
}
100106

107+
-(void)setVolume:(CGFloat)volume{
108+
if ([[[UIDevice currentDevice] systemVersion] compare:@"10.0" options:NSNumericSearch] == NSOrderedDescending){
109+
if (volume < 0 || volume > 1){
110+
return;
111+
}
112+
_volume = volume;
113+
[audioPlayer setVolume:volume fadeDuration:0];
114+
}
115+
}
116+
101117
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
102118
self.playing = NO;
103119
}
@@ -167,6 +183,23 @@ static int stop (lua_State *L) {
167183
return 0;
168184
}
169185

186+
static int setVolume(lua_State *L){
187+
//设置音量接口只有在iOS10.0以上才生效
188+
LVUserDataInfo *user = (LVUserDataInfo *)lua_touserdata(L, 1);
189+
if (user){
190+
LVAudioPlayer *player = (__bridge LVAudioPlayer *)(user->object);
191+
if (player){
192+
if( lua_gettop(L)>=2 ) {
193+
float volume = lua_tonumber(L, 2);
194+
195+
[player setVolume:volume];
196+
}
197+
}
198+
}
199+
200+
return 0;
201+
}
202+
170203
static int __gc (lua_State *L) {
171204
LVUserDataInfo * user = (LVUserDataInfo *)lua_touserdata(L, 1);
172205
releaseUserDataAudioPlayer(user);
@@ -190,6 +223,7 @@ +(int) lvClassDefine:(lua_State *)L globalName:(NSString*) globalName{
190223
const struct luaL_Reg memberFunctions [] = {
191224
{"play", play },
192225
{"stop", stop },
226+
{"setVolume", setVolume},
193227
// pause
194228
// resume
195229
// callback { onComplete onError }

IOS/SDK/LuaViewSDK/Classes/lvsdk/LVCamera.m

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -359,28 +359,6 @@ static int lvTakePicture(lua_State *L){
359359
return 0;
360360
}
361361

362-
static int lvEnableFlash(lua_State *L){
363-
LVUserDataInfo * user = (LVUserDataInfo *)lua_touserdata(L, 1);
364-
if( user ){
365-
LVCamera* camera = (__bridge LVCamera *)(user->object);
366-
if ( lua_gettop(L)>=2 ){
367-
BOOL enable = lua_toboolean(L, 2);
368-
[camera enableFlash:enable];
369-
return 0;
370-
}
371-
}
372-
return 0;
373-
}
374-
375-
static int lvHasCameraFlash(lua_State *L){
376-
//先缺省设置成闪光灯一直存在
377-
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
378-
int available = device.isFlashAvailable;
379-
380-
lua_pushboolean(L, available);
381-
return 1;
382-
}
383-
384362
static int __gc(lua_State *L){
385363
LVUserDataInfo * user = (LVUserDataInfo *)lua_touserdata(L, 1);
386364
releaseUserDataCamera(user);
@@ -419,11 +397,8 @@ +(int) lvClassDefine:(lua_State *)L globalName:(NSString*) globalName{
419397

420398
//方法列表
421399
const struct luaL_Reg memberFunctions [] = {
422-
{"hasPermission", lvHasPermission},
423400
{"enableFaceDetect", lvEnableFaceDetect},
424401
{"takePicture", lvTakePicture},
425-
{"enableFlash", lvEnableFlash},
426-
{"hasCameraFlash", lvHasCameraFlash},
427402
{"__gc", __gc },
428403
{"__tostring", __tostring },
429404
{NULL, NULL}

IOS/SDK/LuaViewSDK/Classes/lvsdk/LVWebView.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)