Commit 6eb6260a authored by Pierre SAGASPE's avatar Pierre SAGASPE Committed by Felix Paul Kühne
Browse files

plex: adding the xib view for the media information (ios 7 or later)


Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent ec6f69a6
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCPlexMediaInformationViewController">
<connections>
<outlet property="badgeUnread" destination="ls6-CJ-vRi" id="eo2-wE-AWl"/>
<outlet property="codec" destination="goK-5h-qRR" id="vul-63-gx6"/>
<outlet property="markMediaButton" destination="jdl-BC-bgB" id="C90-FK-zQA"/>
<outlet property="mediaTitle" destination="8rl-jn-Mwg" id="Oou-jI-sP2"/>
<outlet property="size" destination="7mI-at-CYu" id="1Wl-6H-EeB"/>
<outlet property="summary" destination="a9b-Vy-VUa" id="v5d-1Q-eh9"/>
<outlet property="thumb" destination="HlH-2P-0eo" id="aOi-f8-VnM"/>
<outlet property="view" destination="iN0-l3-epB" id="vWO-dS-ERk"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" indicatorStyle="white" editable="NO" text="Summary" id="a9b-Vy-VUa">
<rect key="frame" x="17" y="342" width="286" height="162"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences" autocorrectionType="no"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="8rl-jn-Mwg">
<rect key="frame" x="17" y="255" width="286" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Video &amp; Audio Codec" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="goK-5h-qRR">
<rect key="frame" x="17" y="283" width="286" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Size &amp; Time" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7mI-at-CYu">
<rect key="frame" x="17" y="313" width="295" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="HlH-2P-0eo">
<rect key="frame" x="16" y="65" width="120" height="175"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
</imageView>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="1CU-w2-CLR">
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<items>
<barButtonItem systemItem="play" id="2qY-WQ-KIy">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<action selector="play:" destination="-1" id="W4E-Q9-uAN"/>
</connections>
</barButtonItem>
<barButtonItem width="12" systemItem="fixedSpace" id="UQK-n7-WSu"/>
<barButtonItem image="Downloads.png" id="fsE-b7-Igz">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<action selector="download:" destination="-1" id="r5k-wP-lHu"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="flexibleSpace" id="05d-5N-zQn"/>
<barButtonItem title="Tag" id="jdl-BC-bgB">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<action selector="markMedia:" destination="-1" id="oL8-Mi-eUt"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="flexibleSpace" id="kV4-Iw-VPi"/>
</items>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="barTintColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</toolbar>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="badgeUnread.png" id="ls6-CJ-vRi">
<rect key="frame" x="94" y="63" width="44" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="268" y="222"/>
</view>
</objects>
<resources>
<image name="Downloads.png" width="17" height="25"/>
<image name="badgeUnread.png" width="35" height="35"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
......@@ -2,7 +2,7 @@
* VLCLocalPlexFolderListViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* Copyright (c) 2014-2015 VideoLAN. All rights reserved.
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Pierre SAGASPE <pierre.sagaspe # me.com>
......
......@@ -2,7 +2,7 @@
* VLCLocalPlexFolderListViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* Copyright (c) 2014-2015 VideoLAN. All rights reserved.
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Pierre SAGASPE <pierre.sagaspe # me.com>
......@@ -11,6 +11,7 @@
*****************************************************************************/
#import "VLCLocalPlexFolderListViewController.h"
#import "VLCPlexMediaInformationViewController.h"
#import "VLCPlexParser.h"
#import "VLCLocalNetworkListCell.h"
#import "VLCAppDelegate.h"
......@@ -265,7 +266,7 @@
ObjList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath];
NSString *URLofSubtitle = nil;
if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
URLofSubtitle = [self _getFileSubtitleFromPlexServer:ObjList modeStream:YES];
URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:ObjList modeStream:YES];
NSURL *itemURL = [NSURL URLWithString:[[ObjList objectAtIndex:0] objectForKey:@"keyMedia"]];
if (itemURL) {
......@@ -296,7 +297,7 @@
mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath];
NSString *URLofSubtitle = nil;
if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
URLofSubtitle = [self _getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
NSURL *itemURL = [NSURL URLWithString:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"]];
if (itemURL) {
......@@ -319,28 +320,6 @@
}
}
- (NSString *)_getFileSubtitleFromPlexServer:(NSMutableArray *)mutableMediaObject modeStream:(BOOL)modeStream
{
NSURL *url = [NSURL URLWithString:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"]];
NSData *receivedSub = [NSData dataWithContentsOfURL:url];
NSArray *searchPaths = nil;
if (modeStream)
searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
else
searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = [searchPaths objectAtIndex:0];
NSString *FileSubtitlePath = [[directoryPath stringByAppendingPathComponent:[[[mutableMediaObject objectAtIndex:0] objectForKey:@"namefile"] stringByDeletingPathExtension]] stringByAppendingPathExtension:[[mutableMediaObject objectAtIndex:0] objectForKey:@"codecSubtitle"]];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:FileSubtitlePath]) {
[fileManager createFileAtPath:FileSubtitlePath contents:nil attributes:nil];
if (![fileManager fileExistsAtPath:FileSubtitlePath])
APLog(@"file creation failed, no data was saved");
}
[receivedSub writeToFile:FileSubtitlePath atomically:YES];
return FileSubtitlePath;
}
- (void)swipeRightGestureAction:(UIGestureRecognizer *)recognizer
{
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:[recognizer locationInView:self.tableView]];
......@@ -401,7 +380,7 @@
NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
if (size < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
[self _getFileSubtitleFromPlexServer:ObjList modeStream:NO];
[_PlexParser getFileSubtitleFromPlexServer:ObjList modeStream:NO];
[self _downloadFileFromMediaItem:ObjList];
[cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
......@@ -476,38 +455,43 @@
VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[[self tableView] cellForRowAtIndexPath:swipedIndexPath];
[ObjList addObject:[_mutableObjectList objectAtIndex:[self.tableView indexPathForCell:swipedCell].row]];
NSString *title = [[ObjList objectAtIndex:0] objectForKey:@"title"];
NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
NSString *mediaSize = [NSByteCountFormatter stringFromByteCount:size countStyle:NSByteCountFormatterCountStyleFile];
NSString *durationInSeconds = [[ObjList objectAtIndex:0] objectForKey:@"duration"];
NSString *audioCodec = [[ObjList objectAtIndex:0] objectForKey:@"audioCodec"];
if (!audioCodec)
audioCodec = @"no track";
NSString *videoCodec = [[ObjList objectAtIndex:0] objectForKey:@"videoCodec"];
if (!videoCodec)
videoCodec = @"no track";
NSString *message = [NSString stringWithFormat:@"%@ (%@)\naudio(%@) video(%@)", mediaSize, durationInSeconds, audioCodec, videoCodec];
NSString *summary = [NSString stringWithFormat:@"%@", [[ObjList objectAtIndex:0] objectForKey:@"summary"]];
VLCAlertView *alertView = [[VLCAlertView alloc] initWithTitle:title message:message cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:@[NSLocalizedString(@"BUTTON_PLAY", nil), NSLocalizedString(@"BUTTON_DOWNLOAD", nil)]];
if (![summary isEqualToString:@""]) {
UITextView *textView = [[UITextView alloc] initWithFrame:alertView.bounds];
textView.text = summary;
textView.editable = NO;
[alertView setValue:textView forKey:@"accessoryView"];
}
alertView.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
if (!cancelled) {
if (buttonIndex == 2)
[self triggerDownloadForCell:cell];
else
[self _playMediaItem:ObjList];
if (SYSTEM_RUNS_IOS7_OR_LATER) {
VLCPlexMediaInformationViewController *targetViewController = [[VLCPlexMediaInformationViewController alloc] initPlexMediaInformation:ObjList serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:_PlexServerPath];
[[self navigationController] pushViewController:targetViewController animated:YES];
} else {
NSString *title = [[ObjList objectAtIndex:0] objectForKey:@"title"];
NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
NSString *mediaSize = [NSByteCountFormatter stringFromByteCount:size countStyle:NSByteCountFormatterCountStyleFile];
NSString *durationInSeconds = [[ObjList objectAtIndex:0] objectForKey:@"duration"];
NSString *audioCodec = [[ObjList objectAtIndex:0] objectForKey:@"audioCodec"];
if (!audioCodec)
audioCodec = @"no track";
NSString *videoCodec = [[ObjList objectAtIndex:0] objectForKey:@"videoCodec"];
if (!videoCodec)
videoCodec = @"no track";
NSString *message = [NSString stringWithFormat:@"%@ (%@)\naudio(%@) video(%@)", mediaSize, durationInSeconds, audioCodec, videoCodec];
NSString *summary = [NSString stringWithFormat:@"%@", [[ObjList objectAtIndex:0] objectForKey:@"summary"]];
VLCAlertView *alertView = [[VLCAlertView alloc] initWithTitle:title message:message cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:@[NSLocalizedString(@"BUTTON_PLAY", nil), NSLocalizedString(@"BUTTON_DOWNLOAD", nil)]];
if (![summary isEqualToString:@""]) {
UITextView *textView = [[UITextView alloc] initWithFrame:alertView.bounds];
textView.text = summary;
textView.editable = NO;
[alertView setValue:textView forKey:@"accessoryView"];
}
};
[alertView show];
alertView.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
if (!cancelled) {
if (buttonIndex == 2)
[self triggerDownloadForCell:cell];
else
[self _playMediaItem:ObjList];
}
};
[alertView show];
}
}
}
@end
@end
\ No newline at end of file
/*****************************************************************************
* VLCPlexMediaInformationViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
*
* Authors: Pierre Sagaspe <pierre.sagaspe # me.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface VLCPlexMediaInformationViewController : UIViewController
@property (nonatomic, strong) IBOutlet UIImageView *thumb;
@property (nonatomic, strong) IBOutlet UILabel *mediaTitle;
@property (nonatomic, strong) IBOutlet UILabel *codec;
@property (nonatomic, strong) IBOutlet UILabel *size;
@property (nonatomic, strong) IBOutlet UITextView *summary;
@property (nonatomic, strong) IBOutlet UIImageView *badgeUnread;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *markMediaButton;
- (IBAction)play:(id)sender;
- (IBAction)download:(id)sender;
- (IBAction)markMedia:(id)sender;
- (id)initPlexMediaInformation:(NSMutableArray *)mediaInformation serverAddress:(NSString *)serverAddress portNumber:(NSString *)portNumber atPath:(NSString *)path;
@end
/*****************************************************************************
* VLCPlexMediaInformationViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
*
* Authors: Pierre Sagaspe <pierre.sagaspe # me.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCPlexMediaInformationViewController.h"
#import "VLCPlexParser.h"
#import "VLCAppDelegate.h"
#import "UIBarButtonItem+Theme.h"
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
@interface VLCPlexMediaInformationViewController ()
{
NSMutableArray *_mutableMediaInformation;
NSString *_PlexServerAddress;
NSString *_PlexServerPort;
NSString *_PlexServerPath;
VLCPlexParser *_PlexParser;
}
@end
@implementation VLCPlexMediaInformationViewController
- (id)initPlexMediaInformation:(NSMutableArray *)mediaInformation serverAddress:(NSString *)serverAddress portNumber:(NSString *)portNumber atPath:(NSString *)path
{
self = [super init];
if (self) {
_mutableMediaInformation = [[NSMutableArray alloc] init];
[_mutableMediaInformation addObjectsFromArray:mediaInformation];
_PlexServerAddress = serverAddress;
_PlexServerPort = portNumber;
_PlexServerPath = path;
_PlexParser = [[VLCPlexParser alloc] init];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor VLCDarkBackgroundColor]];
[self.summary setBackgroundColor:[UIColor VLCDarkBackgroundColor]];
self.automaticallyAdjustsScrollViewInsets = NO;
NSString *title = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"title"];
NSString *thumbPath = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"thumb"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:thumbPath]]];
NSInteger size = [[[_mutableMediaInformation objectAtIndex:0] objectForKey:@"size"] integerValue];
NSString *mediaSize = [NSByteCountFormatter stringFromByteCount:size countStyle:NSByteCountFormatterCountStyleFile];
NSString *durationInSeconds = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"duration"];
NSString *displaySize = [NSString stringWithFormat:@"%@ (%@)", mediaSize, durationInSeconds];
NSString *tag = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"state"];
NSString *displaySummary = [NSString stringWithFormat:@"%@", [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"summary"]];
NSString *audioCodec = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"audioCodec"];
if (!audioCodec)
audioCodec = @"no track";
NSString *videoCodec = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"videoCodec"];
if (!videoCodec)
videoCodec = @"no track";
NSString *displayCodec = [NSString stringWithFormat:@"audio(%@) video(%@)", audioCodec, videoCodec];
NSString *grandparentTitle = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"grandparentTitle"];
if (grandparentTitle)
self.title = grandparentTitle;
[self.thumb setImage:image];
[self.mediaTitle setText:title];
[self.codec setText:displayCodec];
[self.size setText:displaySize];
[self.summary setText:displaySummary];
if ([tag isEqualToString:@"watched"]) {
[self.badgeUnread setHidden:YES];
[self.markMediaButton setTitle:NSLocalizedString(@"PLEX_UNWATCHED", nil)];
} else if ([tag isEqualToString:@"unwatched"]) {
[self.badgeUnread setHidden:NO];
[self.markMediaButton setTitle:NSLocalizedString(@"PLEX_WATCHED", nil)];
} else {
[self.badgeUnread setHidden:NO];
[self.markMediaButton setEnabled:NO];
}
[self.badgeUnread setNeedsDisplay];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
#pragma mark - Specifics
- (void)_playMediaItem:(NSMutableArray *)mutableMediaObject
{
NSString *newPath = nil;
NSString *keyValue = [[mutableMediaObject objectAtIndex:0] objectForKey:@"key"];
if ([keyValue rangeOfString:@"library"].location == NSNotFound)
newPath = [_PlexServerPath stringByAppendingPathComponent:keyValue];
else
newPath = keyValue;
if ([[[mutableMediaObject objectAtIndex:0] objectForKey:@"container"] isEqualToString:@"item"]) {
[mutableMediaObject removeAllObjects];
mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath];
NSString *URLofSubtitle = nil;
if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
URLofSubtitle = [_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:YES];
NSURL *itemURL = [NSURL URLWithString:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"]];
if (itemURL) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openMovieWithExternalSubtitleFromURL:itemURL externalSubURL:URLofSubtitle];
}
}
}
- (void)_download:(NSMutableArray *)mutableMediaObject
{
NSString *path = [[mutableMediaObject objectAtIndex:0] objectForKey:@"key"];
[mutableMediaObject removeAllObjects];
mutableMediaObject = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:path];
NSInteger size = [[[mutableMediaObject objectAtIndex:0] objectForKey:@"size"] integerValue];
if (size < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
if ([[mutableMediaObject objectAtIndex:0] objectForKey:@"keySubtitle"])
[_PlexParser getFileSubtitleFromPlexServer:mutableMediaObject modeStream:NO];
[self _downloadFileFromMediaItem:mutableMediaObject];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [[mutableMediaObject objectAtIndex:0] objectForKey:@"title"], [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil];
[alert show];
}
}
- (void)_downloadFileFromMediaItem:(NSMutableArray *)mutableMediaObject
{
NSURL *itemURL = [NSURL URLWithString:[[mutableMediaObject objectAtIndex:0] objectForKey:@"keyMedia"]];
if (![[itemURL absoluteString] isSupportedFormat]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil) message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), [itemURL absoluteString]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:nil];
[alert show];
} else if (itemURL) {
NSString *fileName = [[mutableMediaObject objectAtIndex:0] objectForKey:@"namefile"];
[[(VLCAppDelegate *)[UIApplication sharedApplication].delegate downloadViewController] addURLToDownloadList:itemURL fileNameOfMedia:fileName];
}
}
#pragma mark - Action
- (IBAction)play:(id)sender
{
[self _playMediaItem:_mutableMediaInformation];
[[self navigationController] popViewControllerAnimated:YES];
}
- (IBAction)download:(id)sender
{
[self _download:_mutableMediaInformation];
[[self navigationController] popViewControllerAnimated:YES];
}
- (IBAction)markMedia:(id)sender
{
NSString *ratingKey = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"ratingKey"];
NSString *tag = [[_mutableMediaInformation objectAtIndex:0] objectForKey:@"state"];
NSInteger status = [_PlexParser MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag];
if (status == 200) {
if ([tag isEqualToString:@"watched"]) {
tag = @"unwatched";
[self.badgeUnread setHidden:NO];
[self.markMediaButton setTitle:NSLocalizedString(@"PLEX_WATCHED", nil)];
} else if ([tag isEqualToString:@"unwatched"]) {
tag = @"watched";
[self.badgeUnread setHidden:YES];
[self.markMediaButton setTitle:NSLocalizedString(@"PLEX_UNWATCHED", nil)];
}
} else
[self.badgeUnread setHidden:YES];
[self.badgeUnread setNeedsDisplay];
[[_mutableMediaInformation objectAtIndex:0] setObject:tag forKey:@"state"];
}
#pragma mark - UI interaction
- (BOOL)shouldAutorotate
{
UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
return YES;
}
@end
\ No newline at end of file
......@@ -13,6 +13,8 @@
260B41DF1A75006300DA89C9 /* OneDriveWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = 260B41D91A75006300DA89C9 /* OneDriveWhite.png */; };
260B41E01A75006300DA89C9 /* OneDriveWhite@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 260B41DA1A75006300DA89C9 /* OneDriveWhite@2x.png */; };
260B41E11A75006300DA89C9 /* OneDriveWhite@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 260B41DB1A75006300DA89C9 /* OneDriveWhite@3x.png */; };
262C71591A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 262C71581A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.m */; };
262C715B1A98FDE300F7ED34 /* VLCPlexMediaInformationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 262C715A1A98FDE300F7ED34 /* VLCPlexMediaInformationViewController.xib */; };
265D511C1922746C00E38383 /* VLCLocalPlexFolderListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */; };
265D511D1922746C00E38383 /* VLCPlexParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 265D511B1922746C00E38383 /* VLCPlexParser.m */; };
26D4AF8D1A78379000D5EC65 /* VLCSharedLibraryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 26D4AF8A1A78379000D5EC65 /* VLCSharedLibraryListViewController.m */; };
......@@ -508,6 +510,9 @@
260B41D91A75006300DA89C9 /* OneDriveWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = OneDriveWhite.png; sourceTree = "<group>"; };
260B41DA1A75006300DA89C9 /* OneDriveWhite@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "OneDriveWhite@2x.png"; sourceTree = "<group>"; };
260B41DB1A75006300DA89C9 /* OneDriveWhite@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "OneDriveWhite@3x.png"; sourceTree = "<group>"; };
262C71571A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCPlexMediaInformationViewController.h; path = Sources/VLCPlexMediaInformationViewController.h; sourceTree = SOURCE_ROOT; };
262C71581A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCPlexMediaInformationViewController.m; path = Sources/VLCPlexMediaInformationViewController.m; sourceTree = SOURCE_ROOT; };
262C715A1A98FDE300F7ED34 /* VLCPlexMediaInformationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = VLCPlexMediaInformationViewController.xib; path = Resources/VLCPlexMediaInformationViewController.xib; sourceTree = SOURCE_ROOT; };
265D51181922746C00E38383 /* VLCLocalPlexFolderListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCLocalPlexFolderListViewController.h; path = Sources/VLCLocalPlexFolderListViewController.h; sourceTree = SOURCE_ROOT; };
265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLocalPlexFolderListViewController.m; path = Sources/VLCLocalPlexFolderListViewController.m; sourceTree = SOURCE_ROOT; };
265D511A1922746C00E38383 /* VLCPlexParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCPlexParser.h; path = Sources/VLCPlexParser.h; sourceTree = SOURCE_ROOT; };
......@@ -1803,6 +1808,8 @@
7D30F3D4183AB2F100FFC021 /* VLCLocalServerFolderListViewController.m */,
265D51181922746C00E38383 /* VLCLocalPlexFolderListViewController.h */,
265D51191922746C00E38383 /* VLCLocalPlexFolderListViewController.m */,
262C71571A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.h */,
262C71581A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.m */,
26D4AF891A78379000D5EC65 /* VLCSharedLibraryListViewController.h */,
26D4AF8A1A78379000D5EC65 /* VLCSharedLibraryListViewController.m */,
7D30F3D5183AB2F100FFC021 /* VLCLocalServerListViewController.h */,
......@@ -2136,6 +2143,7 @@
9B9231C3185A703700F89498 /* VLCFutureNetworkLoginViewController.xib */,
7DBBF193183AB4300009A339 /* VLCOpenNetworkStreamViewController.xib */,
7D89787C185DF794009BAB5D /* VLCFutureOpenNetworkStreamViewController.xib */,
262C715A1A98FDE300F7ED34 /* VLCPlexMediaInformationViewController.xib */,
);
name = "Download & Network";
sourceTree = "<group>";
......@@ -2891,6 +2899,7 @@
26FAE63919240C2E00A43737 /* PlexServerIcon@1x.png in Resources */,
7D27EC1419DF30CB00EF0370 /* pad.png in Resources */,
7DBBF19B183AB4300009A339 /* VLCCloudStorageTableViewCell~iphone.xib in Resources */,
262C715B1A98FDE300F7ED34 /* VLCPlexMediaInformationViewController.xib in Resources */,
4115E5FE197977850071C4B9 /* tableViewIcon.png in Resources */,
7DFC38E31A45F24D002476CB /* checkbox@3x.png in Resources */,
7D27EC1319DF30CB00EF0370 /* laptop@3x.png in Resources */,
......@@ -3259,6 +3268,7 @@
7D3784C3183A9938009EE944 /* VLCStatusLabel.m in Sources */,
7D3784C8183A9972009EE944 /* NSString+SupportedMedia.m in Sources */,
7D3784C9183A9972009EE944 /* UIDevice+VLC.m in Sources */,
262C71591A98FA9200F7ED34 /* VLCPlexMediaInformationViewController.m in Sources */,
7D3784CC183A99BA009EE944 /* PAPasscodeViewController.m in Sources */,
7D3784E9183A9A15009EE944 /* main.m in Sources */,
7D30F3C2183AB24C00FFC021 /* VLCHTTPConnection.m in Sources */,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment