小说绘上架版本
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// WXYZ_ADPangoinVideo.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by LL on 2020/7/29.
|
||||
// Copyright © 2020 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAdvertisementBasicView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_ADPangolinVideo : TFAdvertisementBasicView
|
||||
|
||||
//- (void)show;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// WXYZ_ADPangoinVideo.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by LL on 2020/7/29.
|
||||
// Copyright © 2020 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_ADPangolinVideo.h"
|
||||
#import <MediaPlayer/MediaPlayer.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
@interface WXYZ_ADPangolinVideo ()
|
||||
// 观看视频前的音量大小
|
||||
@property (nonatomic ,assign) CGFloat initialVolume;
|
||||
@property (nonatomic ,weak) MPVolumeView *volumeView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_ADPangolinVideo
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (void)hide
|
||||
{
|
||||
[TFPromptManager hideLoading];
|
||||
[self removeFromSuperview];
|
||||
// 穿山甲广告视频播放结束后会设置成AVAudioSessionCategorySoloAmbient模式导致有声或听书被停止播放
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
|
||||
[self restoreVolume];
|
||||
});
|
||||
}
|
||||
|
||||
// 恢复音量
|
||||
- (void)restoreVolume {
|
||||
UISlider *volumeSlider = nil;
|
||||
for (UIView *obj in self.volumeView.subviews) {
|
||||
if ([obj.class.description isEqualToString:@"MPVolumeSlider"]) {
|
||||
volumeSlider = (UISlider *)obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.volumeView.showsVolumeSlider = YES;
|
||||
[volumeSlider setValue:self.initialVolume animated:NO];
|
||||
[volumeSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
|
||||
[self.volumeView sizeToFit];
|
||||
}
|
||||
|
||||
- (MPVolumeView *)volumeView {
|
||||
if (!_volumeView) {
|
||||
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(-100, -100, 40, 40)];
|
||||
_volumeView = volumeView;
|
||||
[self.window addSubview:volumeView];
|
||||
}
|
||||
return _volumeView;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// WXYZ_ADPangolinView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/7/25.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAdvertisementBasicView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_ADPangolinView : TFAdvertisementBasicView
|
||||
// 广告关闭时的回调
|
||||
@property (nonatomic ,copy) void(^closeBlock)(void);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// WXYZ_ADPangolinView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/7/25.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_ADPangolinView.h"
|
||||
#import "WXYZ_ADPangolinVideo.h"
|
||||
#import "TFReaderSettingHelper.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "UIView+LayoutCallback.h"
|
||||
|
||||
@interface WXYZ_ADPangolinView ()
|
||||
|
||||
@property (nonatomic, weak) UILabel *titleLabel;
|
||||
@property (nonatomic, weak) UILabel *subtitle;
|
||||
/// 高度比例
|
||||
@property (nonatomic, assign) CGFloat heightScale;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_ADPangolinView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame advertisementType:(TFAdvertisementType)type advertisementPosition:(TFAdvertisementPosition)position
|
||||
{
|
||||
if (self = [super initWithFrame:frame advertisementType:type advertisementPosition:position]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
if (self.position == TFAdvertisementPositionEnd && self.type == TFAdvertisementTypeNovel) {
|
||||
UILabel *subtitle = [[UILabel alloc] init];
|
||||
self.subtitle = subtitle;
|
||||
subtitle.backgroundColor = [UIColor clearColor];
|
||||
UIColor *textColor = [TFReaderSettingHelper sharedManager].getReaderTextColor;
|
||||
subtitle.textColor = textColor;
|
||||
subtitle.font = kFont14;
|
||||
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
|
||||
subtitle.text = [NSString stringWithFormat:@"%@%@", delegate.checkSettingModel.ad_status_setting.video_ad_text ?: @"", @">"];
|
||||
[self addSubview:subtitle];
|
||||
subtitle.frameBlock = ^(UIView * _Nonnull view) {
|
||||
[view addBorderLineWithBorderWidth:1.0 borderColor:textColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom];
|
||||
};
|
||||
subtitle.userInteractionEnabled = YES;
|
||||
[subtitle addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(watchVideo)]];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel = titleLabel;
|
||||
titleLabel.backgroundColor = [UIColor clearColor];
|
||||
titleLabel.text = TFLocalizedString(@"点击/滑动可继续阅读");
|
||||
textColor = [textColor colorWithAlphaComponent:0.4];
|
||||
titleLabel.textColor = textColor;
|
||||
titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
titleLabel.font = kFont17;
|
||||
[self addSubview:titleLabel];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setAdvertModel:(TFAdvertModel *)advertModel
|
||||
{
|
||||
[super setAdvertModel:advertModel];
|
||||
|
||||
self.heightScale = 1.0 / 1.2;
|
||||
if (advertModel.ad_width > 0 && advertModel.ad_height > 0) {
|
||||
self.heightScale = (CGFloat)advertModel.ad_height / advertModel.ad_width;
|
||||
}
|
||||
if (self.position == TFAdvertisementPositionEnd) {
|
||||
self.heightScale = 1.0 / 1.2;
|
||||
}
|
||||
}
|
||||
/// 观看激励视频
|
||||
- (void)watchVideo
|
||||
{
|
||||
WXYZ_ADPangolinVideo *video = [[WXYZ_ADPangolinVideo alloc] initWithFrame:CGRectZero advertisementType:self.type advertisementPosition:self.position];
|
||||
|
||||
// [video show];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user