Browse Source

1.视频预览

huangxiaodong 1 year ago
parent
commit
738c98c040

+ 30 - 15
创维盒子/双子星云手机/Class/Set/previewFile/videoPlayByAVPlayerViewController.m

@@ -37,6 +37,13 @@
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
     [self.view addSubview:self.containerView];
+    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.bottom.mas_equalTo(0);
+        make.top.mas_equalTo(self.navBarBGView.mas_bottom);
+    }];
+    
     self.playerManager = [[ZFAVPlayerManager alloc] init];
     /// 播放器相关
     self.player = [ZFPlayerController playerWithPlayerManager:self.playerManager containerView:self.containerView];
@@ -48,19 +55,20 @@
     /// 播放完成
     self.player.playerDidToEnd = ^(id  _Nonnull asset) {
         @zf_strongify(self)
-        [self.player.currentPlayerManager replay];
+        //[self.player.currentPlayerManager replay];
         [self.player playTheNext];
         if (!self.player.isLastAssetURL) {
-            NSString *title = [NSString stringWithFormat:@"视频标题%zd",self.player.currentPlayIndex];
-            [self.controlView showTitle:title coverURLString:nil fullScreenMode:ZFFullScreenModeLandscape];
+//            NSString *title = [NSString stringWithFormat:@"视频标题%zd",self.player.currentPlayIndex];
+//            [self.controlView showTitle:title coverURLString:nil fullScreenMode:ZFFullScreenModeLandscape];
         } else {
             [self.player stop];
         }
     };
     
+    self.player.playerPlayFailed = ^(id<ZFPlayerMediaPlayback>  _Nonnull asset, id  _Nonnull error) {
+        HLog(@"%@----%@",asset,error);
+    };
     
-    [self.controlView showTitle:@"自定义控制层" coverURLString:nil fullScreenMode:ZFFullScreenModeAutomatic];
-
 }
 
 - (void)viewWillAppear:(BOOL)animated {
@@ -71,16 +79,23 @@
 
 //http://transfertest.armclouding.com:10006/getFile?path=/storage/C47D-46D2/mp4/loginVideo.mp4
     
-    NSString *filePath = _VideoDataMode.path;
-    NSString *urlStr = ksharedAppDelegate.NASFileService;
-    NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
-    
-    fileUrl = @"http://transfertest.armclouding.com:10010/getFile?path=/sdcard/bb.mp4";
-    fileUrl = [fileUrl  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    
-    NSURL * sourceMovieURL= [NSURL URLWithString:fileUrl];
-    
-    self.playerManager.assetURL = sourceMovieURL;
+    if(!self.playerManager.assetURL){
+        NSString *filePath = _VideoDataMode.path;
+        NSString *urlStr = ksharedAppDelegate.NASFileService;
+        NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
+        NSString *showUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
+        //HLog(@"%@",fileUrl);
+        //fileUrl = @"http://transfertest.armclouding.com:10010/getFile?path=/sdcard/bb.mp4";
+        fileUrl = [fileUrl  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        
+        NSURL * sourceMovieURL= [NSURL URLWithString:fileUrl];
+        
+        self.playerManager.assetURL = sourceMovieURL;
+        
+        self.titleLabel.text = _VideoDataMode.name;
+        [self.controlView showTitle:@"" coverURLString:showUrl fullScreenMode:ZFFullScreenModeAutomatic];
+    }
+
 }
 
 - (void)viewWillDisappear:(BOOL)animated {

+ 2 - 2
创维盒子/双子星云手机/Class/Set/previewFile/view/imageCollectionViewCell.m

@@ -147,10 +147,10 @@
     
     [_imageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:defaultImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
         if(image){
-            HLog(@"11图片1:%@",imageURL.absoluteString);
+            //HLog(@"11图片1:%@",imageURL.absoluteString);
         }
         else{
-            HLog(@"11图片0:%@",imageURL.absoluteString);
+            //HLog(@"11图片0:%@",imageURL.absoluteString);
         }
         
     }];