Commit b511e4c7 authored by 曹云霄's avatar 曹云霄

修改项说明:

parent 7a0dd3ee
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init]; CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init];
TOAttachmentEntity *attachment = self.afficheResult.attachmentUrls[indexPath.row-1]; TOAttachmentEntity *attachment = self.afficheResult.attachmentUrls[indexPath.row-1];
wkWebView.pdfURLString = attachment.fileUrl; wkWebView.urlString = attachment.fileUrl;
[self presentViewController:wkWebView animated:YES completion:nil]; [self presentViewController:wkWebView animated:YES completion:nil];
} }
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
{ {
//播放窗口 //播放窗口
VideoHelperViewController *videoWindow = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoHelperViewController"]; VideoHelperViewController *videoWindow = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoHelperViewController"];
videoWindow.videoUrl = @"http://mpvideo-test.b0.upaiyun.com/5813998fb092e5771.mp4"; videoWindow.learningItemUrl = @"http://mpvideo-test.b0.upaiyun.com/5813998fb092e5771.mp4";
videoWindow.view.frame = CGRectMake(0, NavigationHeight, ScreenWidth*2/3, ScreenHeight/2); videoWindow.view.frame = CGRectMake(0, NavigationHeight, ScreenWidth*2/3, ScreenHeight/2);
[self addChildViewController:videoWindow]; [self addChildViewController:videoWindow];
[self.view addSubview:videoWindow.view]; [self.view addSubview:videoWindow.view];
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
page.rows = 9999; page.rows = 9999;
studyListModel.page = page; studyListModel.page = page;
[self CreateMBProgressHUDLoding]; [self CreateMBProgressHUDLoding];
NSLog(@"%@",[studyListModel toDictionary]);
[[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(STUDYLIST) WithCallClass:weakSelf WithRequestType:ZERO WithParameter:studyListModel WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(STUDYLIST) WithCallClass:weakSelf WithRequestType:ZERO WithParameter:studyListModel WithReturnValueBlock:^(id returnValue) {
NSLog(@"%@",[returnValue JSONString]); NSLog(@"%@",[returnValue JSONString]);
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
/** /**
播放路径 播放路径
*/ */
@property (nonatomic,copy) NSString *videoUrl; @property (nonatomic,copy) NSString *learningItemUrl;
/** /**
放大缩小 boolValue(true 全屏) 放大缩小 boolValue(true 全屏)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#import "VIMediaCache.h" #import "VIMediaCache.h"
@interface VideoHelperViewController () @interface VideoHelperViewController ()<UIDocumentInteractionControllerDelegate>
@property (nonatomic,strong) AVPlayer *customPlayer; @property (nonatomic,strong) AVPlayer *customPlayer;
@property (nonatomic,strong) AVPlayerItem *playerItem; @property (nonatomic,strong) AVPlayerItem *playerItem;
...@@ -43,13 +43,26 @@ ...@@ -43,13 +43,26 @@
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideOrShowNavigationBarAndToolBar)]]; [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideOrShowNavigationBarAndToolBar)]];
} }
#pragma mark -
- (void)judgeVideoOrPPT
{
NSURL *movieURL = [NSURL URLWithString:self.learningItemUrl];
NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; // 初始化视频媒体文件
NSInteger second = 0;
second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
//NSLog(@"movie duration : %d", second);
NSLog(@"%ld",second);
}
#pragma mark - SetUp AVPlayer #pragma mark - SetUp AVPlayer
- (void)setUpAVPlayer - (void)setUpAVPlayer
{ {
VIResourceLoaderManager *resourceLoaderManager = [VIResourceLoaderManager new]; VIResourceLoaderManager *resourceLoaderManager = [VIResourceLoaderManager new];
self.resourceLoaderManager = resourceLoaderManager; self.resourceLoaderManager = resourceLoaderManager;
self.playerItem = [resourceLoaderManager playerItemWithURL:[NSURL URLWithString:self.videoUrl]]; self.playerItem = [resourceLoaderManager playerItemWithURL:[NSURL URLWithString:self.learningItemUrl]];
VICacheConfiguration *configuration = [VICacheManager cacheConfigurationForURL:[NSURL URLWithString:self.videoUrl]]; VICacheConfiguration *configuration = [VICacheManager cacheConfigurationForURL:[NSURL URLWithString:self.learningItemUrl]];
if (configuration.progress >= 1.0) { if (configuration.progress >= 1.0) {
NSLog(@"缓存完成"); NSLog(@"缓存完成");
} }
......
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init]; CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init];
NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(DRAW),lotteryId,drawid,orderNumber]; NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(DRAW),lotteryId,drawid,orderNumber];
NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""]; NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""];
wkWebView.pdfURLString = newServer; wkWebView.urlString = newServer;
[wkWebView setLuckyDrawFinishBlock:^(NSDictionary *result) { [wkWebView setLuckyDrawFinishBlock:^(NSDictionary *result) {
complete(result); complete(result);
}]; }];
......
...@@ -796,7 +796,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -796,7 +796,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init]; CustomWKWebViewController *wkWebView = [[CustomWKWebViewController alloc]init];
NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(DRAW),lotteryId,@"",orderNumber]; NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(DRAW),lotteryId,@"",orderNumber];
NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""]; NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""];
wkWebView.pdfURLString = newServer; wkWebView.urlString = newServer;
[wkWebView setLuckyDrawFinishBlock:^(NSDictionary *result) { [wkWebView setLuckyDrawFinishBlock:^(NSDictionary *result) {
complete(result); complete(result);
}]; }];
...@@ -1032,7 +1032,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -1032,7 +1032,7 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSURL),[Shoppersmanager manager].Shoppers.employee.departid,self.orderCode]; NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSURL),[Shoppersmanager manager].Shoppers.employee.departid,self.orderCode];
NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""]; NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""];
CustomWKWebViewController *pdfvc = [[CustomWKWebViewController alloc]init]; CustomWKWebViewController *pdfvc = [[CustomWKWebViewController alloc]init];
pdfvc.pdfURLString = newServer; pdfvc.urlString = newServer;
[weakSelf presentViewController:pdfvc animated:YES completion:nil]; [weakSelf presentViewController:pdfvc animated:YES completion:nil];
}else if ([button.currentTitle isEqualToString:@"撤销订单"]) }else if ([button.currentTitle isEqualToString:@"撤销订单"])
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/** /**
* PDF文件URL * PDF文件URL
*/ */
@property (nonatomic,copy) NSString *pdfURLString; @property (nonatomic,copy) NSString *urlString;
/** /**
* 抽奖完成 * 抽奖完成
......
...@@ -8,12 +8,22 @@ ...@@ -8,12 +8,22 @@
#import "CustomWKWebViewController.h" #import "CustomWKWebViewController.h"
#import <WebKit/WebKit.h> #import <WebKit/WebKit.h>
@interface CustomWKWebViewController ()<WKNavigationDelegate,WKScriptMessageHandler> @interface CustomWKWebViewController ()<WKNavigationDelegate,WKScriptMessageHandler,UIScrollViewDelegate>
@property (nonatomic,strong) WKWebView *webView; @property (nonatomic,strong) WKWebView *webView;
@property (nonatomic,strong) WKWebViewConfiguration *config; @property (nonatomic,strong) WKWebViewConfiguration *config;
@property (nonatomic,strong) UIButton *dismissButton; @property (nonatomic,strong) UIButton *dismissButton;
/**
PPT倒计时
*/
@property (nonatomic,strong) UILabel *countdownLabel;
/**
PPT定时器
*/
@property (nonatomic,strong) NSTimer *timer;
@end @end
@implementation CustomWKWebViewController @implementation CustomWKWebViewController
...@@ -38,25 +48,99 @@ ...@@ -38,25 +48,99 @@
return _config; return _config;
} }
- (WKWebView *)webView
{
if (!_webView) {
_webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:self.config];
_webView.navigationDelegate = self;
[self.view addSubview:_webView];
}
return _webView;
}
- (UILabel *)countdownLabel
{
if (!_countdownLabel) {
_countdownLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-150, 50, 100, 30)];
_countdownLabel.backgroundColor = kMainBlueColor;
_countdownLabel.textAlignment = NSTextAlignmentCenter;
_countdownLabel.layer.masksToBounds = YES;
_countdownLabel.layer.cornerRadius = 3;
_countdownLabel.textColor = [UIColor whiteColor];
[self.view addSubview:_countdownLabel];
}
return _countdownLabel;
}
- (NSTimer *)timer
{
if (!_timer) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
}
return _timer;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self uiConfigAction]; [self determineTheURLFileType];
[self addDismissButton]; [self addDismissButton];
} }
#pragma mark -UI #pragma mark - 判断加载文件类型
- (void)uiConfigAction - (void)determineTheURLFileType
{
if ([self.urlString rangeOfString:@".ppt"].location != NSNotFound) {
// [self loadPPTfileAction];
}else {
[self loadURLfileAction];
}
}
#pragma mark - 加载URL
- (void)loadURLfileAction
{ {
NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes]; NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0]; NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{ [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
NSLog(@"清理缓存成功"); NSLog(@"清理缓存成功");
}]; }];
self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:self.config]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
[self.view addSubview:self.webView]; }
self.webView.navigationDelegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.pdfURLString]]]; #pragma mark - 加载PPT文件
- (void)loadPPTfileAction
{
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.pagingEnabled = YES;
self.webView.scrollView.delegate = self;
self.countdownLabel.text = @"10";
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@" end %f",scrollView.contentOffset.y);
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
self.countdownLabel.text = @"10";
self.webView.scrollView.scrollEnabled = NO;
}
#pragma mark - 浏览PPT倒计时
- (void)timerAction
{
NSInteger number = [self.countdownLabel.text integerValue];
if (number <= 0) {
self.webView.scrollView.scrollEnabled = YES;
self.countdownLabel.text = @"请翻页";
[self.timer invalidate];
self.timer = nil;
}else{
number --;
self.countdownLabel.text = [NSString stringWithFormat:@"%ld",number];
}
} }
#pragma mark - 添加删除按钮 #pragma mark - 添加删除按钮
...@@ -96,7 +180,6 @@ ...@@ -96,7 +180,6 @@
} }
} }
#pragma mark -dismiss #pragma mark -dismiss
- (void)dismissButtonClick - (void)dismissButtonClick
{ {
......
...@@ -214,8 +214,7 @@ static NetworkRequestClassManager *manager = nil; ...@@ -214,8 +214,7 @@ static NetworkRequestClassManager *manager = nil;
NSLog(@"%@", downloadProgress);//下载进度 NSLog(@"%@", downloadProgress);//下载进度
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
//返回下载到哪里(返回值是一个路径) //返回下载到哪里(返回值是一个路径)
NSString *homeDictionary = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0]; NSString *homepath = [kPathCaches stringByAppendingPathComponent:[NSString stringWithFormat:@"PPT/%@",[response suggestedFilename]]];//添加储存的文件名
NSString *homepath = [homeDictionary stringByAppendingPathComponent:[response suggestedFilename]];//添加储存的文件名
return [NSURL fileURLWithPath:homepath]; return [NSURL fileURLWithPath:homepath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
//下载完成走这个block //下载完成走这个block
......
...@@ -111,6 +111,11 @@ ...@@ -111,6 +111,11 @@
#define ZERO 0 #define ZERO 0
#define ONE 1 #define ONE 1
/**
* caches路径
*/
#define kPathCaches [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
/** /**
* 断网标示 * 断网标示
*/ */
......
...@@ -23,7 +23,7 @@ static NSTimeInterval kMCMediaCacheNotifyInterval; ...@@ -23,7 +23,7 @@ static NSTimeInterval kMCMediaCacheNotifyInterval;
+ (void)load { + (void)load {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
[self setCacheDirectory:[NSTemporaryDirectory() stringByAppendingPathComponent:@"vimedia"]]; [self setCacheDirectory:[kPathCaches stringByAppendingPathComponent:@"Video"]];
[self setCacheUpdateNotifyInterval:0.1]; [self setCacheUpdateNotifyInterval:0.1];
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment