12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /*****************************************************************************
- * VLCDetailInterfaceController.m
- * VLC for iOS
- *****************************************************************************
- * Copyright (c) 2015 VideoLAN. All rights reserved.
- * $Id$
- *
- * Authors: Tobias Conradi <videolan # tobias-conradi.de>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- #import "VLCDetailInterfaceController.h"
- #import <MediaLibraryKit/MediaLibraryKit.h>
- #import <MobileVLCKit/MobileVLCKit.h>
- @interface VLCDetailInterfaceController ()
- @property (nonatomic, weak) MLFile *file;
- @end
- @implementation VLCDetailInterfaceController
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- [self.playNowButton setTitle:NSLocalizedString(@"Play now", nil)];
- [self setTitle:NSLocalizedString(@"DETAIL", nil)];
- }
- return self;
- }
- - (void)awakeWithContext:(id)context {
- [super awakeWithContext:context];
- if ([context isKindOfClass:[MLFile class]]) {
- [self configureWithFile:context];
- }
- }
- - (void)willActivate {
- [self.playNowButton setTitle:NSLocalizedString(@"PLAY_NOW", nil)];
- [self setTitle:NSLocalizedString(@"DETAIL", nil)];
- // This method is called when watch view controller is about to be visible to user
- [super willActivate];
- }
- - (void)didDeactivate {
- // This method is called when watch view controller is no longer visible
- [super didDeactivate];
- }
- - (void)configureWithFile:(MLFile *)file {
- self.file = file;
- [self.titleLabel setText:file.title];
- self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
- BOOL playEnabled = file != nil;
- self.playNowButton.enabled = playEnabled;
- UIImage *thumbnail = file.computedThumbnail;
- self.imageView.hidden = thumbnail == nil;
- if (thumbnail) {
- self.imageView.image = thumbnail;
- }
- }
- - (IBAction)playNow {
- NSDictionary *dict = @{@"name":@"playFile",
- @"userInfo":@{
- @"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
- }
- };
- [WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
- [self showNowPlaying:nil];
- }];
- }
- @end
|