VideoPreviewCell.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // VideoPreviewCell.m
  3. // iSales-NPD
  4. //
  5. // Created by Jack on 2017/6/21.
  6. // Copyright © 2017年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "VideoPreviewCell.h"
  9. @interface VideoPreviewCell ()
  10. @property (nonatomic,assign) BOOL isPlay;
  11. @end
  12. @implementation VideoPreviewCell
  13. - (void)setItem:(NSDictionary *)item {
  14. _item = item;
  15. }
  16. - (void)reset {
  17. [self.playerView stopVideo];
  18. self.item = nil;
  19. self.isPlay = NO;
  20. [self.contentView bringSubviewToFront:self.VideoImageView];
  21. }
  22. - (void)play {
  23. if (!self.isPlay) {
  24. if (self.item) {
  25. [self.contentView bringSubviewToFront:self.playerView];
  26. NSDictionary *item = self.item;
  27. NSString* video_code=item[@"code"];
  28. NSString* video_id=[self.playerView Embed2VID:video_code];
  29. NSDictionary *playerVars = @{
  30. @"playsinline" : @1,
  31. @"autoplay" : @(1),
  32. @"rel":@0,
  33. @"showinfo": @0,
  34. @"modestbranding":@0,
  35. @"enablejsapi":@1
  36. };
  37. [self.playerView loadWithVideoId:video_id playerVars:playerVars];
  38. self.playerView.webView.allowsPictureInPictureMediaPlayback=false;
  39. self.isPlay = YES;
  40. }
  41. }
  42. }
  43. @end