Skip to content

Commit ba37cf1

Browse files
committed
Update Sample
1 parent c312fd9 commit ba37cf1

File tree

8 files changed

+197
-7
lines changed

8 files changed

+197
-7
lines changed

SJDBMapProject.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
77BED2EA1F5ED7860024D879 /* SampleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 77BED2E81F5ED7860024D879 /* SampleTableViewCell.m */; };
3939
77BED2EB1F5ED7860024D879 /* SampleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77BED2E91F5ED7860024D879 /* SampleTableViewCell.xib */; };
4040
77BED2EE1F5FA2B20024D879 /* SJDBMapQueryCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 77BED2ED1F5FA2B20024D879 /* SJDBMapQueryCache.m */; };
41+
77BED2FA1F5FC7C20024D879 /* SampleVideoPlayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77BED2F91F5FC7C20024D879 /* SampleVideoPlayViewController.m */; };
42+
77BED3001F5FC9440024D879 /* SampleVideoPlayNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77BED2FF1F5FC9440024D879 /* SampleVideoPlayNavigationController.m */; };
4143
/* End PBXBuildFile section */
4244

4345
/* Begin PBXFileReference section */
@@ -100,6 +102,10 @@
100102
77BED2E91F5ED7860024D879 /* SampleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SampleTableViewCell.xib; sourceTree = "<group>"; };
101103
77BED2EC1F5FA2B10024D879 /* SJDBMapQueryCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SJDBMapQueryCache.h; sourceTree = "<group>"; };
102104
77BED2ED1F5FA2B20024D879 /* SJDBMapQueryCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SJDBMapQueryCache.m; sourceTree = "<group>"; };
105+
77BED2F81F5FC7C20024D879 /* SampleVideoPlayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleVideoPlayViewController.h; sourceTree = "<group>"; };
106+
77BED2F91F5FC7C20024D879 /* SampleVideoPlayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleVideoPlayViewController.m; sourceTree = "<group>"; };
107+
77BED2FE1F5FC9440024D879 /* SampleVideoPlayNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleVideoPlayNavigationController.h; sourceTree = "<group>"; };
108+
77BED2FF1F5FC9440024D879 /* SampleVideoPlayNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleVideoPlayNavigationController.m; sourceTree = "<group>"; };
103109
E559417A2BA48C41C6BC60ED /* Pods-SJDBMapProject.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SJDBMapProject.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SJDBMapProject/Pods-SJDBMapProject.debug.xcconfig"; sourceTree = "<group>"; };
104110
/* End PBXFileReference section */
105111

@@ -254,6 +260,10 @@
254260
children = (
255261
77BED2C11F5EC92B0024D879 /* SampleTableViewController.h */,
256262
77BED2C21F5EC92B0024D879 /* SampleTableViewController.m */,
263+
77BED2F81F5FC7C20024D879 /* SampleVideoPlayViewController.h */,
264+
77BED2F91F5FC7C20024D879 /* SampleVideoPlayViewController.m */,
265+
77BED2FE1F5FC9440024D879 /* SampleVideoPlayNavigationController.h */,
266+
77BED2FF1F5FC9440024D879 /* SampleVideoPlayNavigationController.m */,
257267
);
258268
path = Controller;
259269
sourceTree = "<group>";
@@ -414,6 +424,7 @@
414424
7745B24C1EE5D3A700EC4614 /* Book.m in Sources */,
415425
778252841F3D59AD006F5156 /* SJDatabaseMap+GetInfo.m in Sources */,
416426
7745B2231EE5D39B00EC4614 /* ViewController.m in Sources */,
427+
77BED3001F5FC9440024D879 /* SampleVideoPlayNavigationController.m in Sources */,
417428
778252871F3D59AD006F5156 /* SJDBMapAutoincrementPrimaryKeyModel.m in Sources */,
418429
7782528B1F3D59AD006F5156 /* SJDBMapUnderstandingModel.m in Sources */,
419430
778252861F3D59AD006F5156 /* SJDBMapArrayCorrespondingKeysModel.m in Sources */,
@@ -424,6 +435,7 @@
424435
7782528C1F3D59AD006F5156 /* SJDatabaseMap.m in Sources */,
425436
7745B2201EE5D39B00EC4614 /* AppDelegate.m in Sources */,
426437
7745B21D1EE5D39B00EC4614 /* main.m in Sources */,
438+
77BED2FA1F5FC7C20024D879 /* SampleVideoPlayViewController.m in Sources */,
427439
77BED2C91F5EC9560024D879 /* SampleVideoModel.m in Sources */,
428440
77BED2D71F5ED2C10024D879 /* SampleOrgan.m in Sources */,
429441
77BED2C31F5EC92B0024D879 /* SampleTableViewController.m in Sources */,

SJDBMapProject/AppDelegate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "AppDelegate.h"
1010

11+
#import "SampleVideoPlayNavigationController.h"
12+
1113
@interface AppDelegate ()
1214

1315
@end
@@ -18,7 +20,7 @@ @implementation AppDelegate
1820
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1921
// Override point for customization after application launch.
2022
UIViewController *vc = [NSClassFromString(@"ViewController") new];
21-
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
23+
SampleVideoPlayNavigationController *nav = [[SampleVideoPlayNavigationController alloc] initWithRootViewController:vc];
2224
_window = [UIWindow new];
2325
_window.rootViewController = nav;
2426
[_window makeKeyAndVisible];

SJDBMapProject/Info.plist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
23+
<key>NSAppTransportSecurity</key>
24+
<dict>
25+
<key>NSAllowsArbitraryLoads</key>
26+
<true/>
27+
</dict>
2328
<key>UILaunchStoryboardName</key>
2429
<string>LaunchScreen</string>
2530
<key>UIMainStoryboardFile</key>
@@ -41,10 +46,5 @@
4146
<string>UIInterfaceOrientationLandscapeLeft</string>
4247
<string>UIInterfaceOrientationLandscapeRight</string>
4348
</array>
44-
<key>NSAppTransportSecurity</key>
45-
<dict>
46-
<key>NSAllowsArbitraryLoads</key>
47-
<true/>
48-
</dict>
4949
</dict>
5050
</plist>

SJDBMapProject/Sample/Controller/SampleTableViewController.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#import "SJDatabaseMap.h"
2222

23+
#import "SampleVideoPlayViewController.h"
24+
2325
static NSString *const SampleTableViewCellID = @"SampleTableViewCell";
2426

2527
@interface SampleTableViewController ()
@@ -82,7 +84,7 @@ - (void)_setupView {
8284
}];
8385

8486
NSMutableArray<SampleVideoSection *> *sectionsM = [NSMutableArray new];
85-
for ( int i = 0 ; i < 2000; ++i ) {
87+
for ( int i = 0 ; i < 1000; ++i ) {
8688
SampleVideoSection *section = [SampleVideoSection new];
8789
section.sectionId = i;
8890
section.sectionTitle = [NSString stringWithFormat:@"%04zd", i];
@@ -113,5 +115,12 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
113115
return [NSString stringWithFormat:@"%@", self.sections[section].sectionTitle];
114116
}
115117

118+
#pragma mark -
119+
120+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
121+
SampleVideoModel *video = self.sections[indexPath.section].videos[indexPath.row];
122+
SampleVideoPlayViewController *vc = [[SampleVideoPlayViewController alloc] initWithModel:video];
123+
[self.navigationController pushViewController:vc animated:YES];
124+
}
116125

117126
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// SampleVideoPlayNavigationController.h
3+
// SJDBMapProject
4+
//
5+
// Created by BlueDancer on 2017/9/6.
6+
// Copyright © 2017年 SanJiang. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface SampleVideoPlayNavigationController : UINavigationController
12+
13+
@end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// SampleVideoPlayNavigationController.m
3+
// SJDBMapProject
4+
//
5+
// Created by BlueDancer on 2017/9/6.
6+
// Copyright © 2017年 SanJiang. All rights reserved.
7+
//
8+
9+
#import "SampleVideoPlayNavigationController.h"
10+
11+
// 视频专用 导航控制器
12+
13+
@interface SampleVideoPlayNavigationController ()
14+
15+
@property (nonatomic, strong) UIScreenEdgePanGestureRecognizer *pan;
16+
17+
@end
18+
19+
@implementation SampleVideoPlayNavigationController
20+
21+
- (void)viewDidLoad {
22+
[super viewDidLoad];
23+
#pragma clang diagnostic push
24+
#pragma clang diagnostic ignored "-Wundeclared-selector"
25+
_pan = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self.interactivePopGestureRecognizer.delegate action:@selector(handleNavigationTransition:)];
26+
_pan.edges = UIRectEdgeLeft;
27+
#pragma clang diagnostic pop
28+
[self.view addGestureRecognizer:_pan];
29+
30+
// 禁用系统手势
31+
self.interactivePopGestureRecognizer.enabled = NO;
32+
33+
// Do any additional setup after loading the view.
34+
}
35+
36+
#pragma mark - UIGestureRecognizerDelegate
37+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
38+
return self.childViewControllers.count > 0;
39+
}
40+
41+
// 不旋转
42+
- (BOOL)shouldAutorotate {
43+
return NO;
44+
}
45+
46+
@end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// SampleVideoPlayViewController.h
3+
// SJDBMapProject
4+
//
5+
// Created by BlueDancer on 2017/9/6.
6+
// Copyright © 2017年 SanJiang. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class SampleVideoModel;
12+
13+
@interface SampleVideoPlayViewController : UIViewController
14+
15+
- (instancetype)initWithModel:(SampleVideoModel *)video;
16+
17+
@end
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//
2+
// SampleVideoPlayViewController.m
3+
// SJDBMapProject
4+
//
5+
// Created by BlueDancer on 2017/9/6.
6+
// Copyright © 2017年 SanJiang. All rights reserved.
7+
//
8+
9+
#import "SampleVideoPlayViewController.h"
10+
11+
#import "SampleVideoModel.h"
12+
13+
#import <SJVideoPlayer/SJVideoPlayer.h>
14+
15+
#import <Masonry/Masonry.h>
16+
17+
@interface SampleVideoPlayViewController ()
18+
19+
@property (nonatomic, strong, readwrite) SampleVideoModel *video;
20+
21+
@property (nonatomic, strong, readonly) UIView *playerView;
22+
23+
@end
24+
25+
@implementation SampleVideoPlayViewController
26+
27+
- (instancetype)initWithModel:(SampleVideoModel *)video {
28+
self = [super init];
29+
if ( !self ) return nil;
30+
self.video = video;
31+
return self;
32+
}
33+
34+
- (void)viewDidLoad {
35+
[super viewDidLoad];
36+
37+
self.view.backgroundColor = [UIColor whiteColor];
38+
39+
[self _setupView];
40+
41+
[SJVideoPlayer sharedPlayer].assetURL = [NSURL URLWithString:self.video.videoUrl];
42+
43+
}
44+
45+
- (void)viewWillAppear:(BOOL)animated {
46+
[super viewWillAppear:animated];
47+
[self.navigationController setNavigationBarHidden:YES animated:YES];
48+
}
49+
50+
- (void)viewDidAppear:(BOOL)animated {
51+
[super viewDidAppear:animated];
52+
[self play];
53+
}
54+
55+
- (void)viewWillDisappear:(BOOL)animated {
56+
[super viewWillDisappear:animated];
57+
[self.navigationController setNavigationBarHidden:NO animated:YES];
58+
[self pause];
59+
}
60+
61+
- (void)viewDidDisappear:(BOOL)animated {
62+
[super viewDidDisappear:animated];
63+
[self stop];
64+
}
65+
66+
- (void)play {
67+
[[SJVideoPlayer sharedPlayer] play];
68+
}
69+
70+
- (void)pause {
71+
[[SJVideoPlayer sharedPlayer] pause];
72+
}
73+
74+
- (void)stop {
75+
[[SJVideoPlayer sharedPlayer] stop];
76+
}
77+
78+
- (void)_setupView {
79+
[self.view addSubview:self.playerView];
80+
[self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
81+
make.top.offset(20);
82+
make.leading.trailing.offset(0);
83+
make.height.equalTo(self.playerView.mas_width).multipliedBy(9.0 / 16);
84+
}];
85+
}
86+
87+
- (UIView *)playerView {
88+
return [SJVideoPlayer sharedPlayer].view;
89+
}
90+
91+
@end

0 commit comments

Comments
 (0)