VLCDetailInterfaceController.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // This method is called when watch view controller is about to be visible to user
  27. [super willActivate];
  28. }
  29. - (void)didDeactivate {
  30. // This method is called when watch view controller is no longer visible
  31. [super didDeactivate];
  32. }
  33. - (void)configureWithFile:(MLFile *)file {
  34. self.file = file;
  35. [self.titleLabel setText:file.title];
  36. self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
  37. BOOL playEnabled = file != nil;
  38. self.playNowButton.enabled = playEnabled;
  39. UIImage *thumbnail = file.computedThumbnail;
  40. self.imageView.hidden = thumbnail == nil;
  41. if (thumbnail) {
  42. self.imageView.image = thumbnail;
  43. }
  44. }
  45. - (IBAction)playNow {
  46. NSDictionary *dict = @{@"name":@"playFile",
  47. @"userInfo":@{
  48. @"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
  49. }
  50. };
  51. [WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
  52. [self showNowPlaying:nil];
  53. }];
  54. }
  55. @end