19#import <AVFoundation/AVFoundation.h>
20#import <UIKit/UIKit.h>
25NS_ASSUME_NONNULL_BEGIN
32@protocol VideoViewDelegate <NSObject>
76@property(assign, nonatomic, nullable) id<VideoViewDelegate>
delegate;
78@property(strong, nonatomic, nullable) AVPlayer *
player;
80@property(strong, nonatomic, nullable) AVPlayerLayer *
playerLayer;
82@property(strong, nonatomic, nullable) AVPlayerItem *
playerItem;
84@property(strong, nonatomic, nullable) UIView *
memuView;
108@property(strong, nonatomic, nullable) UIImageView *
posterImg;
112@property(strong, nonatomic, nullable) dispatch_source_t
timerSource;
126- (instancetype)initWithFrame:(CGRect)frame;
141- (void)setMovieUrl:(nullable NSString *)movieUrl
142 posterUrl:(nullable NSString *)posterUrl
143 movieVoiceFlg:(nullable NSString *)movieVoiceFlg;
150- (void)setPosterImgWithUrl:(nullable NSString *)url;
163- (void)soundAction:(nullable UIButton *)sender;
176- (void)playAction:(nullable UIButton *)sender;
183- (void)skipAction:(nullable
id)sender;
211- (void)observeValueForKeyPath:(nullable NSString *)keyPath
212 ofObject:(nullable
id)object
213 change:(nullable NSDictionary *)change
214 context:(nullable
void *)context;
221- (void)playerDidPlayToEndTime:(nullable NSNotification *)notification;
247- (nullable NSString *)timeToString:(
float)time;
280- (void)touchesBegan:(nullable NSSet *)touches withEvent:(nullable UIEvent *)event;
341- (void)appStoreFailLoadNoticeWithError:(nullable NSError *)error;
A vertical gradient between two colours, drawn top to bottom.
Definition GradationView.h:22
An AVPlayer-backed advert-video view with a touch-revealed menu overlay.
Definition VideoView.h:69
GradationView * gradationButtomView
The bottom gradient strip that hosts the store button.
Definition VideoView.h:89
UIButton * backButton
The back button.
Definition VideoView.h:100
void setCacheTimer()
Creates and starts the GCD timer that polls the cached duration twice a second.
Definition VideoView.m:685
AVPlayer * player
The player driving playback.
Definition VideoView.h:78
AVPlayerItem * playerItem
The current item being played.
Definition VideoView.h:82
void clearDelegate()
Clears the delegate pointer.
Definition VideoView.m:923
void menuOn()
Fades the menu overlay in.
Definition VideoView.m:792
UIButton * soundButton
The sound-state indicator (a UIButton with user interaction disabled).
Definition VideoView.h:104
id< VideoViewDelegate > delegate
The lifecycle delegate.
Definition VideoView.h:76
UIButton * playButton
The play/pause button.
Definition VideoView.h:106
dispatch_source_t timerSource
The GCD timer source that polls the cached duration.
Definition VideoView.h:112
void openErrorNotice()
Store lifecycle notice stub (empty in the binary).
Definition VideoView.m:873
void finish()
Pauses, hides the play button, and pins the menu on (finished state).
Definition VideoView.m:565
void pauseTimer()
Suspends the cache timer if it is running.
Definition VideoView.m:706
void syncTimeRemaining()
Refreshes the remaining-time label and reschedules the pause check.
Definition VideoView.m:651
void backAction()
Tears the player down and reports -closeNotice: to the delegate.
Definition VideoView.m:490
void setupTimer()
Installs the periodic remaining-time observer and refreshes the readout once.
Definition VideoView.m:634
void storeAction()
Pauses playback and reports -storeNotice: to the delegate.
Definition VideoView.m:509
BOOL autoPlayFlg
Set when the movie should auto-start as soon as it is ready.
Definition VideoView.h:118
void pause()
Pauses playback and deselects the play button.
Definition VideoView.m:559
void appStoreOpenedNotice()
Store lifecycle notice stub (empty in the binary).
Definition VideoView.m:877
BOOL playFlg
Set once the movie has started playing.
Definition VideoView.h:116
void setAutoPlay()
Marks the view to auto-start playback once the movie is ready.
Definition VideoView.m:375
int menuStatus
The menu overlay state.
Definition VideoView.h:96
id playTimeObserver
The token returned by -addPeriodicTimeObserverForInterval:queue:usingBlock: .
Definition VideoView.h:110
void repeat()
Seeks to the start, replays, and reports -movieStart to the delegate.
Definition VideoView.m:548
void streamingTimeoutNowCheck()
Fires a streaming error if playback still has not begun when the watchdog elapses.
Definition VideoView.m:848
UIButton * storeButton
The store button.
Definition VideoView.h:102
AVPlayerLayer * playerLayer
The layer that renders the player's video.
Definition VideoView.h:80
void appStoreTransitionNotice()
Store lifecycle notice stub (empty in the binary).
Definition VideoView.m:893
void menuOff()
Fades the menu overlay out (only while playing and not in the error or finished state).
Definition VideoView.m:812
void streamingTimeoutWatch()
Arms the streaming-timeout watchdog.
Definition VideoView.m:838
double availableDuration()
Polls how much of the movie has buffered, revealing the play button and firing cache-end.
Definition VideoView.m:726
UIImageView * posterImg
The poster image shown before playback begins.
Definition VideoView.h:108
void appStoreClosedNotice()
Store lifecycle notice stub (empty in the binary).
Definition VideoView.m:885
void cancelTimer()
Cancels and releases the cache timer and any pending timeout check.
Definition VideoView.m:713
void pauseCheck()
Pauses if the play button is currently selected.
Definition VideoView.m:666
void appStoreCloseNotice()
Store lifecycle notice stub (empty in the binary).
Definition VideoView.m:881
void deallocPlayer()
Cancels the timer, removes observers, and releases the player, layer, and item.
Definition VideoView.m:899
UILabel * currentTimeLabel
The label showing the remaining play time.
Definition VideoView.h:98
void streamingError()
Reports the streaming error, tears the player down, and shows the error overlay.
Definition VideoView.m:855
UIView * memuView
The menu overlay container.
Definition VideoView.h:84
GradationView * gradationTopView
The top gradient strip that hosts the back, sound, and time controls.
Definition VideoView.h:86
BOOL errorFlg
Set once a streaming error has been shown, to suppress a second overlay.
Definition VideoView.h:114
void movieAutoStartError()
The movie could not auto-start because it was not yet cached.
void movieError()
The movie could not stream (timeout or buffer stall).
void movieReady()
The movie became ready to play.
void movieEnd()
The movie stopped at its end (or was skipped).
void movieCacheEnd()
The movie finished buffering to the cache.
void movieStart()
The movie started playing.
void movieSoundUse()
The movie is playing with sound.