单军华
2018-07-12 3e8437ae559487362fae3525beb79c534c213a51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//  UIScrollView+ZFPlayer.h
//  ZFPlayer
//
// Copyright (c) 2016年 任子丰 ( http://github.com/renzifeng )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
 
#import <UIKit/UIKit.h>
 
NS_ASSUME_NONNULL_BEGIN
 
/*
 * The scroll derection of scrollView.
 */
typedef NS_ENUM(NSUInteger, ZFPlayerScrollDerection) {
    ZFPlayerScrollDerectionNone = 0,
    ZFPlayerScrollDerectionUp = 1,    // Scroll up
    ZFPlayerScrollDerectionDown = 2   // Scroll Down
};
 
@interface UIScrollView (ZFPlayer)
 
/// Rolling direction switch
@property (nonatomic, assign) BOOL zf_enableScrollHook;
 
/// The indexPath is playing
@property (nonatomic, strong, nullable) NSIndexPath *zf_playingIndexPath;
 
/// The indexPath that should play, the one that lights up.
@property (nonatomic, strong, nullable) NSIndexPath *zf_shouldPlayIndexPath;
 
/// WWANA networks play automatically,default NO.
@property (nonatomic, assign, getter=zf_isWWANAutoPlay) BOOL zf_WWANAutoPlay;
 
/// The player should auto player,default is YES.
@property (nonatomic, assign) BOOL zf_shouldAutoPlay;
 
/// The view tag that the player display in scrollView.
@property (nonatomic, assign) NSInteger zf_containerViewTag;
 
/// Is the video playing.
@property (nonatomic, assign, readonly, getter=zf_isPlaying) BOOL zf_playing;
 
/// The scroll derection of scrollView.
@property (nonatomic, assign) ZFPlayerScrollDerection zf_scrollDerection;
 
/// Does the currently playing cell stop playing when the cell has slid off the screen,defalut is YES.
@property (nonatomic, assign) BOOL zf_stopWhileNotVisible;
 
/// The block invoked When the player did appeared.
@property (nonatomic, copy, nullable) void(^zf_playerDidAppearInScrollView)(NSIndexPath *indexPath);
 
/// The block invoked When the player will disappear.
@property (nonatomic, copy, nullable) void(^zf_playerWillDisappearInScrollView)(NSIndexPath *indexPath);
 
/// The block invoked When the player did disappeared half.
@property (nonatomic, copy, nullable) void(^zf_playerDisappearHalfInScrollView)(NSIndexPath *indexPath);
 
/// The block invoked When the player did disappeared.
@property (nonatomic, copy, nullable) void(^zf_playerDidDisappearInScrollView)(NSIndexPath *indexPath);
 
/// The block invoked When the player did stop scroll.
@property (nonatomic, copy, nullable) void(^zf_scrollViewDidStopScrollCallback)(NSIndexPath *indexPath);
 
/// Filter the cell that should be played when the scroll is stopped (to play when the scroll is stopped)
- (void)zf_filterShouldPlayCellWhileScrolled:(void (^ __nullable)(NSIndexPath *indexPath))handler;
 
/// Filter the cell that should be played while scrolling (you can use this to filter the highlighted cell)
- (void)zf_filterShouldPlayCellWhileScrolling:(void (^ __nullable)(NSIndexPath *indexPath))handler;
 
/// Get the cell according to indexPath
- (UIView *)zf_getCellForIndexPath:(NSIndexPath *)indexPath;
 
/// Scroll to indexPath with animations.
- (void)zf_scrollToRowAtIndexPath:(NSIndexPath *)indexPath completionHandler:(void (^ __nullable)(void))completionHandler;
 
/// ScrollView did stop scroll.
- (void)zf_scrollViewDidStopScroll;
 
@end
 
@interface UIScrollView (ZFPlayerDeprecated)
 
@property (nonatomic, copy, nullable) void(^scrollViewDidStopScroll)(NSIndexPath *indexPath) __attribute__((deprecated("use `zf_scrollViewDidStopScrollCallback` instead.")));
 
/// The indexPath that should play, the one that lights up.
@property (nonatomic, strong, nullable) NSIndexPath *shouldPlayIndexPath __attribute__((deprecated("use `zf_shouldPlayIndexPath` instead.")));
 
@end
 
NS_ASSUME_NONNULL_END