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

修改项说明:学习完成考核开发

parent b511e4c7
//
// AssessmentHeaderView.h
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AssessmentHeaderView : UITableViewCell
/**
问题
*/
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
/**
序列号
*/
@property (weak, nonatomic) IBOutlet UILabel *serialNumberLable;
@end
//
// AssessmentHeaderView.m
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "AssessmentHeaderView.h"
@implementation AssessmentHeaderView
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AssessmentTableViewCell.h
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AssessmentTableViewCell : UITableViewCell
/**
题号
*/
@property (weak, nonatomic) IBOutlet UIButton *titleNumberButton;
/**
答案
*/
@property (weak, nonatomic) IBOutlet UILabel *answerTitleLabel;
@end
//
// AssessmentTableViewCell.m
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "AssessmentTableViewCell.h"
@implementation AssessmentTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AssessmentViewController.h
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "BaseViewController.h"
@interface AssessmentViewController : BaseViewController
/**
考核tableview
*/
@property (weak, nonatomic) IBOutlet UITableView *AssessmentTableView;
/**
考核标题
*/
@property (weak, nonatomic) IBOutlet UILabel *AssessmentTitleLabel;
/**
考核时间
*/
@property (weak, nonatomic) IBOutlet UILabel *AssessmentTimeLabel;
/**
学习任务ID
*/
@property (nonatomic,copy) NSString *taskId;
@end
//
// AssessmentViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/12/6.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "AssessmentViewController.h"
#import "AssessmentHeaderView.h"
#import "AssessmentTableViewCell.h"
@interface AssessmentViewController ()<UITableViewDelegate,UITableViewDataSource>
@end
@implementation AssessmentViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self uiConfigAction];
[self getExaminationQuestions];
}
#pragma mark - 设置UI
- (void)uiConfigAction
{
}
#pragma mark - 获取考题
- (void)getExaminationQuestions
{
WS(weakSelf);
[self CreateMBProgressHUDLoding];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(STUDYITEMDETAIL),self.taskId] WithCallClass:weakSelf WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
NSLog(@"%@",[returnValue JSONString]);
if ([returnValue[@"code"] isEqualToNumber:@0]) {
TOStudyTaskEntity *taskDetails = [[TOStudyTaskEntity alloc]initWithDictionary:returnValue[@"data"] error:nil];
}else {
[weakSelf ErrorMBProgressView:returnValue[@"message"]];
}
} WithErrorCodeBlock:^(id errorCodeValue) {
} WithFailureBlock:^(NSError *error) {
}];
}
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AssessmentTableViewCell *assessmentCell = [tableView dequeueReusableCellWithIdentifier:@"AssessmentTableViewCell" forIndexPath:indexPath];
return assessmentCell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
AssessmentHeaderView *headerView = [tableView dequeueReusableCellWithIdentifier:@"AssessmentHeaderView"];
return headerView;
}
@end
//
// CustomStudyEntity.h
// Lighting
//
// Created by 曹云霄 on 2016/12/5.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "opple_objc_json_client.h"
@interface CustomStudyEntity : TOStudyTaskEntity
/**
学习简介高度
*/
@property (nonatomic,assign) CGFloat contentHeight;
/**
导师介绍高度
*/
@property (nonatomic,assign) CGFloat teacherIntroHeight;
@end
//
// CustomStudyEntity.m
// Lighting
//
// Created by 曹云霄 on 2016/12/5.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "CustomStudyEntity.h"
@implementation CustomStudyEntity
- (CGFloat)contentHeight
{
if (!_contentHeight) {
_contentHeight = [self calculateStudyIntroductionHeight:self.contentString]+78;
}
return _contentHeight;
}
- (CGFloat)teacherIntroHeight
{
if (!_teacherIntroHeight) {
_teacherIntroHeight = [self calculateStudyIntroductionHeight:self.teacherIntro]+108;
}
return _teacherIntroHeight;
}
#pragma mark - 计算高度
- (CGFloat)calculateStudyIntroductionHeight:(NSString *)content
{
CGSize s = [content boundingRectWithSize:CGSizeMake(ScreenWidth*2/3-28*2, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
return s.height;
}
@end
......@@ -8,12 +8,26 @@
#import "BaseViewController.h"
@protocol BeginAssessmentDelegate <NSObject>
- (void)beginAssessment:(CustomStudyEntity *)studyEntity;
@end
@interface LearningCompleteViewController : BaseViewController
@property (nonatomic,weak) id<BeginAssessmentDelegate>delegate;
/**
获得积分
*/
@property (weak, nonatomic) IBOutlet UILabel *obtainIntegralLabel;
/**
数据源
*/
@property (nonatomic,strong) CustomStudyEntity *studyEntity;
@end
......@@ -21,6 +21,11 @@
#pragma mark - 开始考核
- (IBAction)startEvaluationButtonClickAction:(UIButton *)sender {
if ([self.delegate respondsToSelector:@selector(beginAssessment:)]) {
[self.delegate beginAssessment:self.studyEntity];
}
}
@end
......@@ -13,8 +13,10 @@
/**
学习项ID
学习项
*/
@property (nonatomic,copy) NSString *studyTypeID;
@property (nonatomic,copy) TOStudyTypeEntity *studyTypeEntity;
@end
......@@ -10,15 +10,18 @@
#import "VideoHelperViewController.h"
#import "VideoListViewController.h"
#import "VideoDetailViewController.h"
#import "CustomWKWebViewController.h"
#import "LearningCompleteViewController.h"
#import "AssessmentViewController.h"
@interface OnlineLearningDetailViewController ()
@interface OnlineLearningDetailViewController ()<SelectStudyItemDelegate,VideoPlayerDelegate,BeginAssessmentDelegate>
/**
学习项详情
学习数据
*/
@property (nonatomic,strong) StudyTypeResponse *studyResponse;
@property (nonatomic,strong) StudyTaskResponse *studyResult;
@property (nonatomic,strong) WYPopoverController *settingsPopoverController;
@end
......@@ -58,13 +61,15 @@
{
//播放窗口
VideoHelperViewController *videoWindow = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoHelperViewController"];
videoWindow.learningItemUrl = @"http://mpvideo-test.b0.upaiyun.com/5813998fb092e5771.mp4";
videoWindow.view.frame = CGRectMake(0, NavigationHeight, ScreenWidth*2/3, ScreenHeight/2);
videoWindow.delegate = self;
[self addChildViewController:videoWindow];
[self.view addSubview:videoWindow.view];
//播放列表
VideoListViewController *playList = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"VideoListViewController"];
playList.view.frame = CGRectMake(ScreenWidth*2/3 + 5, NavigationHeight, ScreenWidth/3-5, ScreenHeight-64);
playList.studyItemTitleLabel.text = self.studyTypeEntity.name;
playList.delegate = self;
[self addChildViewController:playList];
[self.view addSubview:playList.view];
//播放简介
......@@ -98,19 +103,18 @@
WS(weakSelf);
StudyTaskCondition *studyListModel = [[StudyTaskCondition alloc]init];
studyListModel.employeeIdEquals = [Shoppersmanager manager].Shoppers.employee.fid;
studyListModel.typeEquals = self.studyTypeID;
studyListModel.typeEquals = self.studyTypeEntity.fid;
DataPage *page = [[DataPage alloc] init];
page.page = ONE;
page.rows = 9999;
studyListModel.page = page;
[self CreateMBProgressHUDLoding];
NSLog(@"%@",[studyListModel toDictionary]);
[[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(STUDYLIST) WithCallClass:weakSelf WithRequestType:ZERO WithParameter:studyListModel WithReturnValueBlock:^(id returnValue) {
NSLog(@"%@",[returnValue JSONString]);
[weakSelf RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) {
weakSelf.studyResponse = [[StudyTypeResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
weakSelf.studyResult = [[StudyTaskResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
[weakSelf transferData:weakSelf.studyResult];
}else {
[weakSelf ErrorMBProgressView:returnValue[@"message"]];
}
......@@ -122,5 +126,64 @@
}];
}
#pragma mark - 选中学习项
- (void)seleStudyItemCellIndex:(NSIndexPath *)indexPath
{
VideoDetailViewController *studyDetailVc = [self.childViewControllers lastObject];
studyDetailVc.indexPath = indexPath;
VideoHelperViewController *videoVc = [self.childViewControllers firstObject];
RsStudyTask *studyEntity = self.studyResult.studyEntity[indexPath.section];
CustomStudyEntity *studyList = studyEntity.studyTasks[indexPath.row];
if ([studyList.attachment.fileUrl rangeOfString:@".mp4"].location != NSNotFound) {
videoVc.learningItem = studyList;
videoVc.videoTitleLabel.text = studyList.title;
}else if ([studyList.attachment.fileUrl rangeOfString:@".ppt"].location != NSNotFound) {
[videoVc resetPlayer];
CustomWKWebViewController *pdfvc = [[CustomWKWebViewController alloc]init];
pdfvc.urlString = studyList.attachment.fileUrl;
[self presentViewController:pdfvc animated:YES completion:nil];
}
}
#pragma mark - 视频播放完成
- (void)videoPlayFinish:(CustomStudyEntity *)studyEntity
{
LearningCompleteViewController *assessmentVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"LearningCompleteViewController"];
assessmentVc.delegate = self;
assessmentVc.studyEntity = studyEntity;
assessmentVc.preferredContentSize = CGSizeMake(520, 450);
self.settingsPopoverController = [[WYPopoverController alloc] initWithContentViewController:assessmentVc];
self.settingsPopoverController.wantsDefaultContentAppearance = NO;
self.settingsPopoverController.theme.fillBottomColor = [UIColor clearColor];
self.settingsPopoverController.theme.fillTopColor = [UIColor clearColor];
self.settingsPopoverController.theme.glossShadowColor = [UIColor clearColor];
[self.settingsPopoverController presentPopoverAsDialogAnimated:YES
options:WYPopoverAnimationOptionFadeWithScale];
}
#pragma mark - 开始考核
- (void)beginAssessment:(CustomStudyEntity *)studyEntity
{
WS(weakSelf);
[self.settingsPopoverController dismissPopoverAnimated:YES completion:^{
AssessmentViewController *assessmentVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"AssessmentViewController"];
assessmentVc.taskId = studyEntity.fid;
[weakSelf.navigationController pushViewController:assessmentVc animated:YES];
}];
}
#pragma mark - 赋值
- (void)transferData:(StudyTaskResponse *)result
{
VideoListViewController *studyListVC = self.childViewControllers[1];
studyListVC.datasArray = result.studyEntity;
VideoDetailViewController *studyDetailsVC = self.childViewControllers[2];
studyDetailsVC.datasArray = result.studyEntity;
studyDetailsVC.indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
}
@end
......@@ -76,7 +76,7 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
OnlineLearningDetailViewController *studyDetail = [[[self class] getLearningCenterStoryboardClass]instantiateViewControllerWithIdentifier:@"OnlineLearningDetailViewController"];
studyDetail.studyTypeID = [self.studyTypeArray[indexPath.row] fid];
studyDetail.studyTypeEntity = self.studyTypeArray[indexPath.row];
[self.navigationController pushViewController:studyDetail animated:YES];
}
......
......@@ -31,4 +31,9 @@
*/
@property (weak, nonatomic) IBOutlet UILabel *studyItemLabel;
/**
学习列表数据源
*/
@property (nonatomic,strong) TOStudyTaskEntity *model;
@end
//
// SpecifiedTableViewCell.h
// Lighting
//
// Created by 曹云霄 on 2016/12/5.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SpecifiedTableViewCell : UITableViewCell
/**
针对人员
*/
@property (weak, nonatomic) IBOutlet UILabel *specifiedPersonLabel;
/**
数据源
*/
@property (nonatomic,strong) CustomStudyEntity *studyEntity;
@end
//
// SpecifiedTableViewCell.m
// Lighting
//
// Created by 曹云霄 on 2016/12/5.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "SpecifiedTableViewCell.h"
@implementation SpecifiedTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setStudyEntity:(CustomStudyEntity *)studyEntity
{
_studyEntity = studyEntity;
self.specifiedPersonLabel.text = _studyEntity.suitabler;
}
@end
......@@ -11,15 +11,17 @@
@interface VideoDetailIntroTableViewCell : UITableViewCell
/**
介绍项标题
*/
@property (weak, nonatomic) IBOutlet UILabel *studyIntroTitleLabel;
/**
简介
*/
@property (weak, nonatomic) IBOutlet UILabel *studyIntroDetailTitleLabel;
/**
数据源
*/
@property (nonatomic,strong) CustomStudyEntity *studyEntity;
@end
......@@ -15,10 +15,14 @@
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
- (void)setStudyEntity:(CustomStudyEntity *)studyEntity
{
_studyEntity = studyEntity;
if (_studyEntity) {
self.studyIntroDetailTitleLabel.text = _studyEntity.contentString;
self.studyIntroDetailTitleLabel.height = _studyEntity.contentHeight-78;
}
}
@end
......@@ -31,4 +31,14 @@ typedef NS_ENUM(NSInteger,CellType){
*/
@property (weak, nonatomic) IBOutlet UITableView *studyItemDetailsTableView;
/**
学习列表数据源
*/
@property (nonatomic,strong) NSArray *datasArray;
/**
选择项
*/
@property (nonatomic,strong) NSIndexPath *indexPath;
@end
......@@ -10,14 +10,11 @@
#import "VideoDetailIntroTableViewCell.h"
#import "VideoLecturerTableViewCell.h"
#import "WkWebViewViewController.h"
#import "SpecifiedTableViewCell.h"
@interface VideoDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
/**
简介高度
*/
@property (nonatomic,assign) CGFloat introductionHeight;
@end
......@@ -26,28 +23,20 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self addChildWebViewController];
[self setUpTableView];
}
#pragma mark - UITableView
- (void)setUpTableView
#pragma mark - 选中学习内容下标
- (void)setIndexPath:(NSIndexPath *)indexPath
{
self.studyItemDetailsTableView.tableFooterView = [UIView new];
_indexPath = indexPath;
[self.studyItemDetailsTableView reloadData];
}
#pragma mark - WKWebView
- (void)addChildWebViewController
#pragma mark - UITableView
- (void)setUpTableView
{
WS(weakSelf);
WkWebViewViewController *webView = [[WkWebViewViewController alloc]initWithReturnContentSize:^(CGFloat contentHeight) {
weakSelf.introductionHeight = contentHeight;
webView.view.frame = CGRectMake(0, 0, ScreenWidth, contentHeight);
[weakSelf.studyItemDetailsTableView reloadData];
}];
self.introductionHeight = 100;//默认值
webView.view.frame = CGRectMake(0, 0, ScreenWidth, self.introductionHeight);
[self addChildViewController:webView];
self.studyItemDetailsTableView.tableFooterView = [UIView new];
}
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
......@@ -57,19 +46,24 @@
case StudyItemIntroCell:
{
VideoDetailIntroTableViewCell *itemDetailCell = [tableView dequeueReusableCellWithIdentifier:@"VideoDetailIntroTableViewCell" forIndexPath:indexPath];
[itemDetailCell.contentView addSubview:self.childViewControllers[0].view];
RsStudyTask *studyEntity = self.datasArray[self.indexPath.section];
itemDetailCell.studyEntity = studyEntity.studyTasks[self.indexPath.row];
return itemDetailCell;
}
break;
case LecturerIntroCell:
{
VideoLecturerTableViewCell *lectureCell = [tableView dequeueReusableCellWithIdentifier:@"VideoLecturerTableViewCell" forIndexPath:indexPath];
RsStudyTask *studyEntity = self.datasArray[self.indexPath.section];
lectureCell.studyEntity = studyEntity.studyTasks[self.indexPath.row];
return lectureCell;
}
break;
case ContraposePersonCell:
{
VideoDetailIntroTableViewCell *scopeCell = [tableView dequeueReusableCellWithIdentifier:@"VideoDetailIntroTableViewCell" forIndexPath:indexPath];
SpecifiedTableViewCell *scopeCell = [tableView dequeueReusableCellWithIdentifier:@"SpecifiedTableViewCell" forIndexPath:indexPath];
RsStudyTask *studyEntity = self.datasArray[self.indexPath.section];
scopeCell.studyEntity = studyEntity.studyTasks[self.indexPath.row];
return scopeCell;
}
break;
......@@ -87,21 +81,17 @@
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
RsStudyTask *studyEntity = self.datasArray[self.indexPath.section];
CustomStudyEntity *study = studyEntity.studyTasks[self.indexPath.row];
switch (indexPath.row) {
case StudyItemIntroCell:
{
return self.introductionHeight;
}
return study.contentHeight;
break;
case LecturerIntroCell:
{
return 130;
}
return study.teacherIntroHeight;
break;
case ContraposePersonCell:
{
return 100;
}
break;
default:
......@@ -110,4 +100,11 @@
return 0;
}
@end
......@@ -8,7 +8,14 @@
#import "BaseViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "VIMediaCache.h"
@protocol VideoPlayerDelegate <NSObject>
@optional
- (void)videoPlayFinish:(CustomStudyEntity *)studyEntity;
@end
@interface VideoHelperViewController : BaseViewController
......@@ -17,6 +24,11 @@
播放Layer
*/
@property (nonatomic,strong) AVPlayerLayer *playerLayer;
@property (nonatomic,strong) AVPlayer *customPlayer;
@property (nonatomic,strong) AVPlayerItem *playerItem;
@property (nonatomic,strong) id avplayerServer;
@property (nonatomic,strong) VIResourceLoaderManager *resourceLoaderManager;
@property (nonatomic,weak) id<VideoPlayerDelegate> delegate;
/**
视频导航栏
......@@ -56,12 +68,17 @@
/**
播放路径
*/
@property (nonatomic,copy) NSString *learningItemUrl;
@property (nonatomic,copy) CustomStudyEntity *learningItem;
/**
放大缩小 boolValue(true 全屏)
*/
@property (nonatomic,copy) void(^zoomButtonClickBlock)(BOOL boolValue);
/**
重置播放器
*/
- (void)resetPlayer;
@end
......@@ -7,15 +7,11 @@
//
#import "VideoHelperViewController.h"
#import "VIMediaCache.h"
@interface VideoHelperViewController ()<UIDocumentInteractionControllerDelegate>
@property (nonatomic,strong) AVPlayer *customPlayer;
@property (nonatomic,strong) AVPlayerItem *playerItem;
@property (nonatomic,strong) id avplayerServer;
@property (nonatomic,strong) VIResourceLoaderManager *resourceLoaderManager;
/**
导航栏、工具类是否隐藏
......@@ -30,9 +26,7 @@
{
[super viewDidLoad];
[self uiConfigAction];
[self setUpAVPlayer];
[self addAVPlayerKVO];
[self addProgressObserver];
}
#pragma mark - UI
......@@ -46,7 +40,7 @@
#pragma mark -
- (void)judgeVideoOrPPT
{
NSURL *movieURL = [NSURL URLWithString:self.learningItemUrl];
NSURL *movieURL = [NSURL URLWithString:self.learningItem.attachment.fileUrl];
NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; // 初始化视频媒体文件
......@@ -56,22 +50,34 @@
NSLog(@"%ld",second);
}
#pragma mark - 播放地址
- (void)setLearningItem:(CustomStudyEntity *)learningItem
{
_learningItem = learningItem;
[self resetPlayer];
if (_learningItem) {
[self setUpAVPlayer];
[self addAVPlayerKVO];
[self addProgressObserver];
}
}
#pragma mark - SetUp AVPlayer
- (void)setUpAVPlayer
{
VIResourceLoaderManager *resourceLoaderManager = [VIResourceLoaderManager new];
self.resourceLoaderManager = resourceLoaderManager;
self.playerItem = [resourceLoaderManager playerItemWithURL:[NSURL URLWithString:self.learningItemUrl]];
VICacheConfiguration *configuration = [VICacheManager cacheConfigurationForURL:[NSURL URLWithString:self.learningItemUrl]];
self.playerItem = [resourceLoaderManager playerItemWithURL:[NSURL URLWithString:self.learningItem.attachment.fileUrl]];
VICacheConfiguration *configuration = [VICacheManager cacheConfigurationForURL:[NSURL URLWithString:self.learningItem.attachment.fileUrl]];
if (configuration.progress >= 1.0) {
NSLog(@"缓存完成");
}
self.customPlayer = [[AVPlayer alloc] initWithPlayerItem:_playerItem];
self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:_customPlayer];
[self CreateMBProgressHUDLoding];
self.customPlayer = [[AVPlayer alloc] initWithPlayerItem:self.playerItem];
self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.customPlayer];
self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
self.playerLayer.frame = CGRectMake(0, 0, ScreenWidth*2/3, ScreenHeight/2);
[self.view.layer insertSublayer:self.playerLayer atIndex:0];
[self CreateMBProgressHUDLoding];
//设置静音模式播放声音
AVAudioSession * session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
......@@ -95,11 +101,14 @@
NSInteger status = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
switch (status) {
case AVPlayerStatusFailed:
self.bufferProgressView.progress = ZERO;
self.playButton.selected = YES;
[self ErrorMBProgressView:@"播放失败"];
break;
case AVPlayerStatusReadyToPlay://正在播放
[self RemoveMBProgressHUDLoding];
self.playItemTotalTimeLabel.text = [NSString stringWithFormat:@"/ %@",[self convertTime:CMTimeGetSeconds(self.playerItem.duration)]];
self.playButton.selected = NO;
break;
default:
break;
......@@ -176,6 +185,9 @@
{
[self.customPlayer seekToTime:kCMTimeZero];
self.playButton.selected = YES;
if ([self.delegate respondsToSelector:@selector(videoPlayFinish:)]) {
[self.delegate videoPlayFinish:self.learningItem];
}
}
#pragma mark - 播放、暂停
......@@ -218,6 +230,16 @@
[self.customPlayer.currentItem.asset cancelLoading];
}
#pragma mark - 重置播放器
- (void)resetPlayer
{
[self.customPlayer pause];
[self.customPlayer seekToTime:kCMTimeZero];
self.bufferProgressView.progress = 0;
self.playingTimeLabel.text = @"00:00";
self.customPlayer = nil;
}
#pragma mark - 释放KVO
- (void)dealloc
{
......
......@@ -11,12 +11,6 @@
@interface VideoLecturerTableViewCell : UITableViewCell
/**
讲师介绍标题
*/
@property (weak, nonatomic) IBOutlet UILabel *lecturerTitleLabel;
/**
讲师头像
*/
......@@ -32,5 +26,9 @@
*/
@property (weak, nonatomic) IBOutlet UILabel *lecurerIntroLabel;
/**
数据源
*/
@property (nonatomic,strong) CustomStudyEntity *studyEntity;
@end
......@@ -15,10 +15,15 @@
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
- (void)setStudyEntity:(CustomStudyEntity *)studyEntity
{
_studyEntity = studyEntity;
if (_studyEntity) {
[self.lecturerImageView sd_setImageWithURL:[NSURL URLWithString:_studyEntity.teacherAttachment.fileUrl] placeholderImage:REPLACEIMAGE];
self.lecturerNameLabel.text = _studyEntity.teacher;
self.lecurerIntroLabel.text = _studyEntity.teacherIntro;
self.lecurerIntroLabel.height = _studyEntity.teacherIntroHeight-108;
}
}
@end
......@@ -31,4 +31,9 @@
*/
@property (weak, nonatomic) IBOutlet UILabel *studyItemTimeLabel;
/**
学习列表数据源
*/
@property (nonatomic,strong) TOStudyTaskEntity *model;
@end
......@@ -15,10 +15,11 @@
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
- (void)setModel:(TOStudyTaskEntity *)model
{
_model = model;
self.studyItemTitleLabel.text = _model.title;
}
@end
......@@ -8,9 +8,19 @@
#import "BaseViewController.h"
@interface VideoListViewController : BaseViewController
/**
选中
*/
@protocol SelectStudyItemDelegate <NSObject>
@required
- (void)seleStudyItemCellIndex:(NSIndexPath *)indexPath;
@end
@interface VideoListViewController : BaseViewController
@property (nonatomic,weak) id<SelectStudyItemDelegate> delegate;
/**
学习列表
......@@ -22,5 +32,8 @@
*/
@property (weak, nonatomic) IBOutlet UILabel *studyItemTitleLabel;
/**
学习列表数据源
*/
@property (nonatomic,strong) NSArray *datasArray;
@end
......@@ -9,6 +9,7 @@
#import "VideoListViewController.h"
#import "VideoListItemTableViewCell.h"
#import "VideoListSectionHeaderView.h"
#import "PPTListItemTableViewCell.h"
@interface VideoListViewController ()<UITableViewDelegate,UITableViewDataSource>
......@@ -25,6 +26,13 @@
[self setUpTableView];
}
#pragma mark - 数据源
- (void)setDatasArray:(NSArray *)datasArray
{
_datasArray = datasArray;
[self.studyListTableView reloadData];
}
#pragma mark - UITableView
- (void)setUpTableView
{
......@@ -36,24 +44,63 @@
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
VideoListItemTableViewCell *studyItemCell = [tableView dequeueReusableCellWithIdentifier:@"VideoListItemTableViewCell" forIndexPath:indexPath];
return studyItemCell;
RsStudyTask *studyEntity = self.datasArray[indexPath.section];
CustomStudyEntity *studyList = studyEntity.studyTasks[indexPath.row];
if ([studyList.attachment.fileUrl rangeOfString:@".ppt"].location != NSNotFound) {
PPTListItemTableViewCell *pptItemCell = [tableView dequeueReusableCellWithIdentifier:@"PPTListItemTableViewCell" forIndexPath:indexPath];
pptItemCell.model = studyList;
return pptItemCell;
}else if ([studyList.attachment.fileUrl rangeOfString:@".mp4"].location != NSNotFound){
VideoListItemTableViewCell *videoItemCell = [tableView dequeueReusableCellWithIdentifier:@"VideoListItemTableViewCell" forIndexPath:indexPath];
videoItemCell.model = studyList;
return videoItemCell;
}
return [UITableViewCell new];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
RsStudyTask *studyTask = self.datasArray[section];
return studyTask.studyTasks.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.datasArray.count;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
VideoListSectionHeaderView *headerView = [tableView dequeueReusableCellWithIdentifier:@"VideoListSectionHeaderView"];
headerView.studyItemSectionLabel.text = [self.datasArray[section] categoryName];
return headerView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return 2;
RsStudyTask *studyEntity = self.datasArray[indexPath.section];
CustomStudyEntity *studyList = studyEntity.studyTasks[indexPath.row];
for (UITableViewCell *cell in self.studyListTableView.visibleCells) {
if ([cell isKindOfClass:[PPTListItemTableViewCell class]]) {
PPTListItemTableViewCell *pptCell = (PPTListItemTableViewCell *)cell;
pptCell.pptButton.selected = NO;
}
if ([cell isKindOfClass:[VideoListItemTableViewCell class]]) {
VideoListItemTableViewCell *videoCell = (VideoListItemTableViewCell *)cell;
videoCell.playButton.selected = NO;
}
}
if ([studyList.attachment.fileUrl rangeOfString:@".ppt"].location != NSNotFound) {
PPTListItemTableViewCell *pptItemCell = [tableView cellForRowAtIndexPath:indexPath];
pptItemCell.pptButton.selected = YES;
}else if ([studyList.attachment.fileUrl rangeOfString:@".mp4"].location != NSNotFound){
VideoListItemTableViewCell *videoItemCell = [tableView cellForRowAtIndexPath:indexPath];
videoItemCell.playButton.selected = YES;
}
if ([self.delegate respondsToSelector:@selector(seleStudyItemCellIndex:)]) {
[self.delegate seleStudyItemCellIndex:indexPath];
}
}
@end
......@@ -297,10 +297,10 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
deductionModel.priority = oldPromotion.prority;
[weakSelf.promotionInformationArray addObject:deductionModel];
} else if (![BaseViewController isBlankString:[oldPromotion.jdEcardDenomation stringValue]]) {
} else if (![BaseViewController isBlankString:[oldPromotion.jdecardDenomation stringValue]]) {
// 京东E卡
PromotionJDECardModel *jdECardModel = [[PromotionJDECardModel alloc]init];
jdECardModel.total = [oldPromotion.jdEcardDenomation integerValue];
jdECardModel.total = [oldPromotion.jdecardDenomation integerValue];
jdECardModel.body = GUIDE;
jdECardModel.type = JDECardAction;
jdECardModel.priority = oldPromotion.prority;
......
This diff is collapsed.
This diff is collapsed.
......@@ -14,16 +14,6 @@
@property (nonatomic,strong) WKWebViewConfiguration *config;
@property (nonatomic,strong) UIButton *dismissButton;
/**
PPT倒计时
*/
@property (nonatomic,strong) UILabel *countdownLabel;
/**
PPT定时器
*/
@property (nonatomic,strong) NSTimer *timer;
@end
@implementation CustomWKWebViewController
......@@ -53,33 +43,11 @@
if (!_webView) {
_webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:self.config];
_webView.navigationDelegate = self;
[self.view addSubview:_webView];
[self.view insertSubview:_webView atIndex:0];
}
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 {
[super viewDidLoad];
......@@ -91,11 +59,7 @@
#pragma mark - 判断加载文件类型
- (void)determineTheURLFileType
{
if ([self.urlString rangeOfString:@".ppt"].location != NSNotFound) {
// [self loadPPTfileAction];
}else {
[self loadURLfileAction];
}
}
#pragma mark - 加载URL
......@@ -106,42 +70,48 @@
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
NSLog(@"清理缓存成功");
}];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
}
#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
#pragma mark - 数据
- (void)setUrlString:(NSString *)urlString
{
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];
}
}
_urlString = urlString;
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]]];
}
//#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 - 添加删除按钮
- (void)addDismissButton
......
......@@ -40,6 +40,7 @@
#import "WYPopoverController.h"
#import "CustomBorderLabel.h"
#import "PNCircleChart.h"
#import "CustomStudyEntity.h"
// Include any system framework and library headers here that should be included in all compilation units.
......
......@@ -28,7 +28,7 @@ static NSString *kURLKey = @"kURLKey";
@implementation VICacheConfiguration
+ (instancetype)configurationWithFilePath:(NSString *)filePath {
filePath = [self configurationFilePathForFilePath:filePath];
// filePath = [self configurationFilePathForFilePath:filePath];
VICacheConfiguration *configuration = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
if (!configuration) {
......
......@@ -105,8 +105,8 @@ static NSString *kCacheScheme = @"VIMediaCache";
}
- (AVPlayerItem *)playerItemWithURL:(NSURL *)url {
NSURL *assetURL = [VIResourceLoaderManager assetURLWithURL:url];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
// NSURL *assetURL = [VIResourceLoaderManager assetURLWithURL:url];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:nil];
[urlAsset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:urlAsset];
if ([playerItem respondsToSelector:@selector(setCanUseNetworkResourcesForLiveStreamingWhilePaused:)]) {
......
This diff is collapsed.
This diff is collapsed.
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