Browse Source

视频播放优化

Steven 6 months ago
parent
commit
251da53296

+ 5 - 15
KulexiuForTeacher/KulexiuForTeacher/Common/MediaMerge/AudioMerge/VideoPlayerView/KSVideoPlayerView.m

@@ -9,6 +9,7 @@
 #import <AVFoundation/AVFoundation.h>
 #import <CloudAccompanyLibrary/AVPlayer+KSSeekSmoothly.h>
 
+
 @interface KSVideoPlayerView ()
 
 @property (nonatomic, strong) AVPlayer *videoPlayer;
@@ -108,27 +109,19 @@
     }];
 }
 
-- (void)resumePlay {
-    if (_isPlaying) {
-        [_videoPlayer pause];
-    }
-    _isPlaying = YES;
-    [self.videoPlayer play];
-}
-
 - (void)puasePlay {
     self.needResume = NO;
     if (_isPlaying) {
         _isPlaying = NO;
-        [_videoPlayer pause];
     }
+    [_videoPlayer pause];
 }
 
 - (void)freePlayer {
     if (_isPlaying) {
         _isPlaying = NO;
-        [_videoPlayer pause];
     }
+    [_videoPlayer pause];
     [self removeAllNoticeAndObserver];
     [self resetPlayer];
 }
@@ -317,16 +310,13 @@
     [_currentItem removeObserver:self forKeyPath:@"loadedTimeRanges"];
 }
 #pragma mark----播放完成后发送通知
--(void)addPlayToEndObserver
-{
+- (void)addPlayToEndObserver {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:_currentItem];
 }
 
 #pragma mark---通知的方法
--(void)playFinished:(NSNotification *)notice
-{
+-(void)playFinished:(NSNotification *)notice {
     //移除所有监听
-    _isPlaying = NO;
     if ([self.delegate respondsToSelector:@selector(videoPlayerFinishedPlay:)]) {
         [self.delegate videoPlayerFinishedPlay:self.videoPlayer];
     }