VLCDetailInterfaceController.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*****************************************************************************
  2. * VLCDetailInterfaceController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCDetailInterfaceController.h"
  13. #import <MediaLibraryKit/MediaLibraryKit.h>
  14. #import <MobileVLCKit/MobileVLCKit.h>
  15. #import "VLCThumbnailsCache.h"
  16. @interface VLCDetailInterfaceController ()
  17. @property (nonatomic, weak) MLFile *file;
  18. @end
  19. @implementation VLCDetailInterfaceController
  20. - (instancetype)init
  21. {
  22. self = [super init];
  23. if (self) {
  24. [self.playNowButton setTitle:NSLocalizedString(@"Play now", nil)];
  25. [self setTitle:NSLocalizedString(@"DETAIL", nil)];
  26. }
  27. return self;
  28. }
  29. - (void)awakeWithContext:(id)context {
  30. [super awakeWithContext:context];
  31. [self addNowPlayingMenu];
  32. if ([context isKindOfClass:[MLFile class]]) {
  33. [self configureWithFile:context];
  34. }
  35. }
  36. - (void)willActivate {
  37. [self.playNowButton setTitle:NSLocalizedString(@"PLAY_NOW", nil)];
  38. [self setTitle:NSLocalizedString(@"DETAIL", nil)];
  39. // This method is called when watch view controller is about to be visible to user
  40. [super willActivate];
  41. }
  42. - (void)didDeactivate {
  43. // This method is called when watch view controller is no longer visible
  44. [super didDeactivate];
  45. }
  46. - (void)configureWithFile:(MLFile *)file {
  47. self.file = file;
  48. [self.titleLabel setText:file.title];
  49. self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
  50. BOOL playEnabled = file != nil;
  51. self.playNowButton.enabled = playEnabled;
  52. UIImage *thumbnail = [VLCThumbnailsCache thumbnailForMediaFile:file];
  53. self.imageView.hidden = thumbnail == nil;
  54. if (thumbnail) {
  55. self.imageView.image = thumbnail;
  56. }
  57. }
  58. - (IBAction)playNow {
  59. NSDictionary *dict = @{@"name":@"playFile",
  60. @"userInfo":@{
  61. @"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
  62. }
  63. };
  64. [WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
  65. [self showNowPlaying:nil];
  66. }];
  67. }
  68. @end