VLCDetailInterfaceController.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. @interface VLCDetailInterfaceController ()
  16. @property (nonatomic, weak) MLFile *file;
  17. @end
  18. @implementation VLCDetailInterfaceController
  19. - (void)awakeWithContext:(id)context {
  20. [super awakeWithContext:context];
  21. if ([context isKindOfClass:[MLFile class]]) {
  22. [self configureWithFile:context];
  23. }
  24. }
  25. - (void)willActivate {
  26. [self.playNowButton setTitle:NSLocalizedString(@"Play now", nil)];
  27. [self setTitle:NSLocalizedString(@"DETAIL", nil)];
  28. // This method is called when watch view controller is about to be visible to user
  29. [super willActivate];
  30. }
  31. - (void)didDeactivate {
  32. // This method is called when watch view controller is no longer visible
  33. [super didDeactivate];
  34. }
  35. - (void)configureWithFile:(MLFile *)file {
  36. self.file = file;
  37. [self.titleLabel setText:file.title];
  38. self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
  39. BOOL playEnabled = file != nil;
  40. self.playNowButton.enabled = playEnabled;
  41. UIImage *thumbnail = file.computedThumbnail;
  42. self.imageView.hidden = thumbnail == nil;
  43. if (thumbnail) {
  44. self.imageView.image = thumbnail;
  45. }
  46. }
  47. - (IBAction)playNow {
  48. NSDictionary *dict = @{@"name":@"playFile",
  49. @"userInfo":@{
  50. @"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
  51. }
  52. };
  53. [WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
  54. [self showNowPlaying:nil];
  55. }];
  56. }
  57. @end