VLCDetailInterfaceController.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. if ([context isKindOfClass:[MLFile class]]) {
  32. [self configureWithFile:context];
  33. }
  34. }
  35. - (void)willActivate {
  36. [self.playNowButton setTitle:NSLocalizedString(@"PLAY_NOW", nil)];
  37. [self setTitle:NSLocalizedString(@"DETAIL", nil)];
  38. // This method is called when watch view controller is about to be visible to user
  39. [super willActivate];
  40. }
  41. - (void)didDeactivate {
  42. // This method is called when watch view controller is no longer visible
  43. [super didDeactivate];
  44. }
  45. - (void)configureWithFile:(MLFile *)file {
  46. self.file = file;
  47. [self.titleLabel setText:file.title];
  48. self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
  49. BOOL playEnabled = file != nil;
  50. self.playNowButton.enabled = playEnabled;
  51. UIImage *thumbnail = [VLCThumbnailsCache thumbnailForMediaFile:file];
  52. self.imageView.hidden = thumbnail == nil;
  53. if (thumbnail) {
  54. self.imageView.image = thumbnail;
  55. }
  56. }
  57. - (IBAction)playNow {
  58. NSDictionary *dict = @{@"name":@"playFile",
  59. @"userInfo":@{
  60. @"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
  61. }
  62. };
  63. [WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
  64. [self showNowPlaying:nil];
  65. }];
  66. }
  67. @end