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