Skip to content

Commit 55bb94c

Browse files
committed
Update code to the latest
1 parent a7fe1ea commit 55bb94c

File tree

40 files changed

+2038
-471
lines changed

40 files changed

+2038
-471
lines changed

Example/VPInterfaceControllerDemo/VPAVPlayerController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern NSString *const VPAVPlayerPlayerbackDidSeekCompleteNotification;
4949

5050
@property (nonatomic, readonly) CGSize videoTrueSize;
5151
@property (nonatomic, readonly) CGRect videoNowRect;
52+
@property (nonatomic, assign, readonly) CGRect getVideoFrame;
5253

5354
@property (nonatomic, weak) id<VPVideoPlayerDelegate> videoPlayerDelagate;
5455

Example/VPInterfaceControllerDemo/VPAVPlayerController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ - (void)dealloc {
139139
[self shutdown];
140140
}
141141

142+
//getVideoFrame
143+
144+
- (CGRect)getVideoFrame {
145+
return self.view.bounds;
146+
}
147+
142148
- (void)prepareToPlay {
143149
if(!_player) {
144150
return;

Example/VPInterfaceControllerDemo/VPSinglePlayerViewController.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ - (void)viewDidLoad {
178178
if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
179179
_mediaControlView.videoSwitchButton.hidden = YES;
180180
_mediaControlView.btnConstraint.constant = 0;
181-
_mediaControlView.videoSwitchButton.selected = NO;
181+
VPIServiceConfig *config = [[VPIServiceConfig alloc] init];
182+
config.type = VPIServiceTypeVideoMode;
183+
config.identifier = _interfaceController.config.identifier;
184+
[_interfaceController startService:VPIServiceTypeVideoMode config:config];
182185
}else {
183186
_mediaControlView.videoSwitchButton.hidden = NO;
184187
_mediaControlView.btnConstraint.constant = 60;
@@ -370,7 +373,7 @@ - (void)simulateButtonDidClicked:(id)sender {
370373
NSString *path = [[NSBundle mainBundle] pathForResource:@"adInfo" ofType:@"json"];
371374
NSDictionary *adInfo = [NSJSONSerialization JSONObjectWithData:[[NSData alloc] initWithContentsOfFile:path] options:NSJSONReadingMutableContainers error:nil];
372375

373-
[_interfaceController navigationWithURL:[NSURL URLWithString:@"LuaView://defaultLuaView?template=os_easy_shop_hotspot.lua&id=5aa5fa5133edbf375fe43fff4"] data:[[adInfo objectForKey:@"launchInfoList"] objectAtIndex:0]];
376+
[_interfaceController navigationWithURL:[NSURL URLWithString:@"LuaView://defaultLuaView?template=os_video_figureStarList_hotspot.lua&id=5aa5fa5133edbf375fe43fff4"] data:[[adInfo objectForKey:@"launchInfoList"] objectAtIndex:0]];
374377

375378
// [_interfaceController navigationWithURL:[NSURL URLWithString:@"LuaView://defaultLuaView?template=os_bubble.lua&id=5aa5fa5133edbf375fe43fff4"] data:[[adInfo objectForKey:@"launchInfoList"] objectAtIndex:0]];
376379

@@ -411,6 +414,7 @@ - (void)addSVGAPlayerName:(NSString *)name {
411414
self.svgPlayer = [[SVGAPlayer alloc]initWithFrame:self.view.bounds];
412415
self.svgPlayer.delegate = self;
413416
self.svgPlayer.loops = 1;
417+
self.svgPlayer.userInteractionEnabled = NO;
414418
[self.view addSubview:self.svgPlayer];
415419
[self.svgPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
416420
make.left.right.top.bottom.equalTo(self.view);
@@ -593,8 +597,6 @@ - (void)initGestureView {
593597

594598
- (void)initInterfaceController {
595599
// [[VPUPDebugSwitch sharedDebugSwitch] switchEnvironment:VPUPDebugStateTest];
596-
NSDate *datenow = [NSDate date];
597-
[VPIConfigSDK setIdentity:[NSString stringWithFormat:@"%f",[datenow timeIntervalSince1970]]];
598600
//videoIdentifier可传协商过唯一ID拼接,并非必须为url
599601
VPInterfaceControllerConfig *config = [[VPInterfaceControllerConfig alloc] init];
600602
config.platformID = [PrivateConfig shareConfig].platformID;
@@ -880,7 +882,7 @@ - (void)vp_interfaceActionNotify:(NSDictionary *)actionDictionary {
880882
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[actionDictionary objectForKey:@"deepLink"]]];
881883
}
882884
else {
883-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"错误" message:@"DeepLink打开失败" preferredStyle:UIAlertControllerStyleAlert];
885+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"错误" message:@"App打开失败" preferredStyle:UIAlertControllerStyleAlert];
884886
__weak typeof(self) weakSelf = self;
885887
UIAlertAction *action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
886888
__strong typeof(self) strongSelf = weakSelf;
@@ -937,6 +939,11 @@ - (NSTimeInterval)videoPlayerCurrentTime {
937939
return _player.currentPlaybackTime;
938940
}
939941

942+
943+
-(CGRect)videoFrame {
944+
return _player.getVideoFrame;
945+
}
946+
940947
- (VPIVideoPlayerSize *)videoPlayerSize {
941948
CGSize screenSize = [UIScreen mainScreen].bounds.size;
942949
VPIVideoPlayerSize *videoPlayerSize = [[VPIVideoPlayerSize alloc] init];

Resources/VideoPlsResources.bundle/lua/main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ local function getTaglist()
352352
return
353353
end
354354
responseData = Native:aesDecrypt(response.encryptData, OS_HTTP_PUBLIC_KEY, OS_HTTP_PUBLIC_KEY)
355-
print("luaview "..responseData)
355+
--print("luaview "..responseData)
356356

357357
response = toTable(responseData)
358358
if (response.resCode ~= "00") then

VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VPInterfaceController.m

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#import "VPLuaOSView.h"
3030
#import "VPLuaAppletsView.h"
31+
#import "VPLuaDesktopView.h"
3132
#import "VPLuaMedia.h"
3233
#import "VPLuaVideoInfo.h"
3334
#import "VPLuaPage.h"
@@ -59,6 +60,8 @@ @interface VPInterfaceController()
5960

6061
@property (nonatomic) VPLuaAppletsView *appletsView;
6162

63+
@property (nonatomic) VPLuaDesktopView *desktopView;
64+
6265
@property (nonatomic, readwrite, strong) VPInterfaceControllerConfig *config;
6366

6467
@property (nonatomic, assign) VPIVideoPlayerOrientation orientationType;
@@ -139,6 +142,7 @@ - (void)initViewWithFrame:(CGRect)frame
139142
_view = [[VPInterfaceClickThroughView alloc] initWithFrame:frame];
140143
[self initOSViewWithFrame:frame];
141144
[self initAppletsViewWithFrame:frame];
145+
[self initDesktopViewWithFrame:frame];
142146
}
143147

144148
- (void)initOSViewWithFrame:(CGRect)frame {
@@ -183,13 +187,41 @@ - (void)initAppletsViewWithFrame:(CGRect)frame {
183187
vpSize.portraitFullScreenWidth = self.videoPlayerSize.portraitFullScreenWidth;
184188
vpSize.portraitFullScreenHeight = self.videoPlayerSize.portraitFullScreenHeight;
185189
vpSize.portraitSmallScreenOriginY = self.videoPlayerSize.portraitSmallScreenOriginY;
186-
_osView.videoPlayerSize = vpSize;
190+
_appletsView.videoPlayerSize = vpSize;
187191
[_appletsView setGetUserInfoBlock:^NSDictionary *(void) {
188192
return [weakSelf getUserInfoDictionary];
189193
}];
190194
[_view addSubview:_appletsView];
191195
}
192196

197+
- (void)initDesktopViewWithFrame:(CGRect)frame {
198+
199+
__weak typeof(self) weakSelf = self;
200+
NSString *platformId = nil;
201+
NSString *videoId = nil;
202+
203+
platformId = _config.platformID;
204+
videoId = _config.identifier;
205+
if (_config.types & VPInterfaceControllerTypeVideoOS) {
206+
[VPLuaSDK setOSType:VPLuaOSTypeVideoOS];
207+
}
208+
else {
209+
[VPLuaSDK setOSType:VPLuaOSTypeLiveOS];
210+
}
211+
_desktopView = [[VPLuaDesktopView alloc] initWithFrame:frame platformId:platformId videoId:videoId extendInfo:_config.extendDict];
212+
VPLuaVideoPlayerSize *vpSize = [[VPLuaVideoPlayerSize alloc] init];
213+
vpSize.portraitSmallScreenHeight = self.videoPlayerSize.portraitSmallScreenHeight;
214+
vpSize.portraitFullScreenWidth = self.videoPlayerSize.portraitFullScreenWidth;
215+
vpSize.portraitFullScreenHeight = self.videoPlayerSize.portraitFullScreenHeight;
216+
vpSize.portraitSmallScreenOriginY = self.videoPlayerSize.portraitSmallScreenOriginY;
217+
_desktopView.videoPlayerSize = vpSize;
218+
[_desktopView setGetUserInfoBlock:^NSDictionary *(void) {
219+
return [weakSelf getUserInfoDictionary];
220+
}];
221+
[_view addSubview:_desktopView];
222+
[_view bringSubviewToFront:_desktopView];
223+
}
224+
193225
- (BOOL)validateSetAttribute {
194226
if(!_canSet) {
195227
//TODO: already start loading, could not set
@@ -229,7 +261,12 @@ - (void)start {
229261
if (_appletsView) {
230262
[_appletsView startLoading];
231263
}
232-
264+
if (!_desktopView) {
265+
[self initDesktopViewWithFrame:self.view.bounds];
266+
}
267+
if (_desktopView) {
268+
[_desktopView startLoading];
269+
}
233270
[self registerStatusNotification];
234271
}
235272

@@ -250,6 +287,9 @@ - (void)notifyVideoScreenChanged:(VPIVideoPlayerOrientation)type {
250287
if (_appletsView) {
251288
[_appletsView updateVideoPlayerOrientation:(VPLuaVideoPlayerOrientation)type];
252289
}
290+
if (_desktopView) {
291+
[_desktopView updateVideoPlayerOrientation:(VPLuaVideoPlayerOrientation)type];
292+
}
253293

254294
CGFloat width = 0;
255295
CGFloat height = 0;
@@ -314,6 +354,12 @@ - (void)stop {
314354
_appletsView = nil;
315355
}
316356

357+
if (_desktopView) {
358+
[_desktopView stop];
359+
[_desktopView removeFromSuperview];
360+
_desktopView = nil;
361+
}
362+
317363
_canSet = YES;
318364
}
319365

@@ -325,8 +371,8 @@ - (void)pauseVideoAd {
325371
if (_osView) {
326372
[_osView pauseVideoAd];
327373
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
328-
@(VPLuaAdActionTypePause), @"ActionType",
329-
@(VPLuaAdEventTypeAction), @"EventType",nil];
374+
@(VPLuaOSActionTypePause), @"osActionType",
375+
@(VPLuaEventTypeOSAction), @"eventType",nil];
330376
[_osView callLuaMethod:@"event" data:dict];
331377
}
332378
}
@@ -335,8 +381,8 @@ - (void)playVideoAd {
335381
if (_osView) {
336382
[_osView playVideoAd];
337383
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
338-
@(VPLuaAdActionTypeResume),@"ActionType",
339-
@(VPLuaAdEventTypeAction), @"EventType",nil];
384+
@(VPLuaOSActionTypeResume),@"osActionType",
385+
@(VPLuaEventTypeOSAction), @"eventType",nil];
340386
[_osView callLuaMethod:@"event" data:dict];
341387
}
342388
}
@@ -632,6 +678,10 @@ - (VPUPVideoPlayerSize *)videoPlayerSize {
632678
return vpupSize;
633679
}
634680

681+
- (CGRect)videoFrame {
682+
return [self.videoPlayerDelegate videoFrame];
683+
}
684+
635685
- (void)registerRoutes {
636686
[self registerLuaViewRoutes];
637687
}
@@ -673,7 +723,7 @@ - (void)registerLuaViewRoutes {
673723
return YES;
674724
}];
675725

676-
//跳转小程序 LuaView://applets?appletId=xxxx&type=x(type: 1横屏,2竖屏)
726+
//跳转小程序 LuaView://applets?appletId=xxxx&type=x(type: 1横屏,2竖屏)&appType=x(appType: 1 lua,2 h5)
677727
//容器内部跳转 LuaView://applets?appletId=xxxx&template=xxxx.lua&id=xxxx&priority=x
678728
[[VPUPRoutes routesForScheme:VPUPRoutesSDKLuaView] addRoute:@"/applets" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
679729

@@ -715,6 +765,37 @@ - (void)registerLuaViewRoutes {
715765

716766
return YES;
717767
}];
768+
769+
[[VPUPRoutes routesForScheme:VPUPRoutesSDKLuaView] addRoute:@"/desktopLuaView" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
770+
771+
if (!weakSelf) {
772+
return NO;
773+
}
774+
__strong typeof(self) strongSelf = weakSelf;
775+
//判定osView是否存在,若不存在,先创建
776+
if (!strongSelf.desktopView) {
777+
[strongSelf initDesktopViewWithFrame:strongSelf.view.bounds];
778+
//TODO MQTT,如果_liveView不存在情况怎么处理
779+
780+
if(!strongSelf.canSet) {
781+
[strongSelf.desktopView startLoading];
782+
}
783+
}
784+
785+
id data = [[parameters objectForKey:VPUPRouteUserInfoKey] objectForKey:@"ActionManagerData"];
786+
if (!data) {
787+
data = [parameters objectForKey:VPUPRouteUserInfoKey];
788+
}
789+
790+
NSDictionary *queryParams = [parameters objectForKey:VPUPRouteQueryParamsKey];
791+
NSString *luaFile = [queryParams objectForKey:@"template"];
792+
if (!luaFile) {
793+
luaFile = [data objectForKey:@"template"];
794+
}
795+
796+
[strongSelf.desktopView loadLua:luaFile data:parameters];
797+
return YES;
798+
}];
718799
}
719800

720801
- (void)unregisterRoutes {
@@ -783,6 +864,7 @@ - (void)startService:(VPIServiceType )type config:(VPIServiceConfig *)config {
783864
serviceConfig.duration = (VPIVideoAdTimeType)config.duration;
784865

785866
self.serviceManager.osView = self.osView;
867+
self.serviceManager.desktopView = self.desktopView;
786868
self.serviceManager.delegate = self;
787869

788870
[self.serviceManager startService:(VPLuaServiceType)type config:serviceConfig];

0 commit comments

Comments
 (0)