Skip to content

Commit 9ab27d8

Browse files
committed
add video ad pause and play api
1 parent a69a4f6 commit 9ab27d8

File tree

8 files changed

+93
-4
lines changed

8 files changed

+93
-4
lines changed

VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VPInterfaceController.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@
121121
*/
122122
- (void)platformCloseActionWebView;
123123

124+
/**
125+
* 暂停中插视频
126+
*/
127+
- (void)pauseVideoAd;
128+
129+
/**
130+
* 播放暂停的中插视频
131+
*/
132+
- (void)playVideoAd;
133+
124134
/**
125135
* controller的生命周期
126136
*/

VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VideoPlsInterfaceControllerSDK/VPInterfaceController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ - (void)platformCloseActionWebView {
265265
[_osView closeActionWebViewForAd:[self.openUrlActionDict objectForKey:@"adID"]];
266266
}
267267

268+
- (void)pauseVideoAd {
269+
[_osView pauseVideoAd];
270+
}
271+
272+
- (void)playVideoAd {
273+
[_osView playVideoAd];
274+
}
275+
268276
- (void)closeInfoView {
269277
if (_osView) {
270278
[_osView closeInfoView];

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/LuaView/VPLuaPlayer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#import <VPLuaViewSDK/LVHeads.h>
1212
#import "VideoPlsUtilsPlatformSDK.h"
1313

14+
extern NSString *const VPLuaPauseVideoPlayerNotification;
15+
1416
@interface VPLuaPlayer : VPUPVideoClip<LVProtocal, LVClassProtocal>
1517

1618
@property (nonatomic, weak) LuaViewCore* lv_luaviewCore;

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/LuaView/VPLuaPlayer.m

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#import <VPLuaViewSDK/LVHeads.h>
1414
#import <AVFoundation/AVFoundation.h>
1515

16+
NSString * const VPLuaPauseVideoPlayerNotification = @"VPLuaPauseVideoPlayerNotification";
17+
1618
@interface VPLuaPlayer () <VPUPVideoClipProtocol>
1719

1820
@end
@@ -30,6 +32,7 @@ - (id)init:(lua_State *)l {
3032
[[AVAudioSession sharedInstance] setActive:YES error:nil];
3133
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
3234
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
35+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pauseVideoPlayer:) name:VPLuaPauseVideoPlayerNotification object:nil];
3336
}
3437
return self;
3538
}
@@ -49,6 +52,22 @@ - (void)volumeChanged:(NSNotification *)notification {
4952
[self updateCurrentPlayerVolume:volume];
5053
}
5154

55+
- (void)pauseVideoPlayer:(NSNotification *)notification {
56+
57+
[self pause];
58+
59+
if (self.videoArray.count > 0) {
60+
VPUPVideo *video = [self.videoArray objectAtIndex:0];
61+
lua_State* l = self.lv_luaviewCore.l;
62+
if( l ){
63+
lua_pushstring(l, [video.url.path UTF8String]);
64+
[self lv_callLuaCallback:@"onPause" key2:nil argN:1];
65+
return;
66+
}
67+
}
68+
[self lv_callLuaCallback:@"onPause" key2:nil argN:0];
69+
}
70+
5271
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
5372
UIView *hitView = [super hitTest:point withEvent:event];
5473
if (hitView == self) {
@@ -253,19 +272,39 @@ - (NSString *)description {
253272
}
254273

255274
- (void)videoClipVideoPreparePlaying:(NSUInteger)index videoUrl:(NSURL *)url {
256-
[self lv_callLuaCallback:@"onPrepare" key2:nil argN:0];
275+
276+
lua_State* l = self.lv_luaviewCore.l;
277+
if( l ){
278+
lua_pushstring(l, [url.path UTF8String]);
279+
}
280+
[self lv_callLuaCallback:@"onPrepare" key2:nil argN:1];
257281
}
258282

259283
- (void)videoClipVideoStartPlaying:(NSUInteger)index videoUrl:(NSURL *)url {
260-
[self lv_callLuaCallback:@"onStart" key2:nil argN:0];
284+
lua_State* l = self.lv_luaviewCore.l;
285+
if( l ){
286+
lua_pushstring(l, [url.path UTF8String]);
287+
}
288+
[self lv_callLuaCallback:@"onStart" key2:nil argN:1];
261289
}
262290

263291
- (void)videoClipVideoFinished:(NSUInteger)index videoUrl:(NSURL *)url {
264-
[self lv_callLuaCallback:@"onFinished" key2:nil argN:0];
292+
lua_State* l = self.lv_luaviewCore.l;
293+
if( l ){
294+
lua_pushstring(l, [url.path UTF8String]);
295+
}
296+
[self lv_callLuaCallback:@"onFinished" key2:nil argN:1];
265297
}
266298

267299
- (void)videoClipAllFinished {
268-
[self lv_callLuaCallback:@"onFinished" key2:nil argN:0];
300+
if (self.videoArray.count > 0) {
301+
VPUPVideo *video = [self.videoArray objectAtIndex:0];
302+
lua_State* l = self.lv_luaviewCore.l;
303+
if( l ){
304+
lua_pushstring(l, [video.url.path UTF8String]);
305+
}
306+
}
307+
[self lv_callLuaCallback:@"onFinished" key2:nil argN:1];
269308
}
270309

271310
- (void)videoClipDidClick:(NSUInteger)index videoUrl:(NSURL *)url {

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/Manager/VPLuaNodeController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575

7676
- (void)closeActionWebViewForAd:(NSString *)adId;
7777

78+
- (void)playVideoAd;
79+
7880
- (void)closeInfoView;
7981

8082
@end

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/Manager/VPLuaNodeController.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
//cont
3434
//static NSMutableArray<VPLuaNodeController *> *avaliableControllers;
3535
const NSInteger VPLuaBaseNodeInfoViewPriority = 2;
36+
const NSInteger VPLuaBaseNodeWedgePriority = 10;
3637

3738
@interface VPLuaNodeController()
3839

@@ -467,6 +468,20 @@ - (void)closeActionWebViewForAd:(NSString *)adId {
467468
}
468469
}
469470

471+
- (void)playVideoAd {
472+
NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
473+
for (VPLuaBaseNode *tempNode in _nodes) {
474+
if (tempNode.priority == VPLuaBaseNodeWedgePriority) {
475+
[array addObject:tempNode];
476+
}
477+
}
478+
if (array.count > 0) {
479+
for (VPLuaBaseNode *tempNode in array) {
480+
[tempNode callMethod:@"show" data:nil];
481+
}
482+
}
483+
}
484+
470485
- (void)closeInfoView {
471486
NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
472487
for (VPLuaBaseNode *tempNode in _nodes) {

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/OS/VPLuaOSView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern NSString *const VPLuaOSLoadCompleteNotification;
3939

4040
- (void)closeActionWebViewForAd:(NSString *)adId;
4141

42+
- (void)pauseVideoAd;
43+
44+
- (void)playVideoAd;
45+
4246
- (void)closeInfoView;
4347

4448
@end

VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VideoPlsLuaViewManagerSDK/VPLua/OS/VPLuaOSView.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "VPLuaServiceManager.h"
1313
#import "VPUPRSAUtil.h"
1414
#import "VPLuaSDK.h"
15+
#import "VPLuaPlayer.h"
1516
#import <objc/message.h>
1617

1718
NSString *const VPOSLuaEndNotification = @"VPOSLuaEndNotification";
@@ -132,6 +133,14 @@ - (void)closeActionWebViewForAd:(NSString *)adId {
132133
[self.luaController closeActionWebViewForAd:adId];
133134
}
134135

136+
- (void)pauseVideoAd {
137+
[[NSNotificationCenter defaultCenter] postNotificationName:VPLuaPauseVideoPlayerNotification object:nil];
138+
}
139+
140+
- (void)playVideoAd {
141+
[self.luaController playVideoAd];
142+
}
143+
135144
- (void)closeInfoView {
136145
[self.luaController closeInfoView];
137146
}

0 commit comments

Comments
 (0)