Commit 00ff7035 authored by Carola's avatar Carola Committed by Felix Paul Kühne
Browse files

better nowplayingview

parent 7d084fff
......@@ -11,7 +11,8 @@ PODS:
- upnpx (1.3.2)
DEPENDENCIES:
- box-ios-sdk-v2 (from `git://github.com/carolanitz/box-ios-sdk-v2.git`, commit `d2df30aa5f76d30910e06f3ef5aff49025de3cf1`)
- box-ios-sdk-v2 (from `git://github.com/carolanitz/box-ios-sdk-v2.git`, commit
`d2df30aa5f76d30910e06f3ef5aff49025de3cf1`)
- GHSidebarNav (= 1.0.0)
- InAppSettingsKit (= 2.2.2)
- OBSlider (= 1.1.0)
......@@ -45,4 +46,4 @@ SPEC CHECKSUMS:
SSKeychain: 88767e903ee8d274ed380e364d96b7a101235286
upnpx: e56e4f26d21c439b2383e03b5ca9082a3d5046a1
COCOAPODS: 0.36.0
COCOAPODS: 0.36.3
......@@ -61,6 +61,12 @@
<string>org.videolan.vlc-ios</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>NSUserActivityTypes</key>
<array>
<string>org.videolan.vlc-ios.librarymode</string>
</array>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleName</key>
<string>VLC for iOS</string>
<key>CFBundlePackageType</key>
......
......@@ -151,6 +151,43 @@
return YES;
}
#pragma mark - Handoff
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType {
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
//Todo maybe show a spinner here
//might need to setup menu
return YES;
}
return NO;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
if([userActivity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
NSDictionary *dict = userActivity.userInfo;
NSInteger row = [(NSNumber *)dict[@"state"] integerValue];
// 0 all
// 1 music
// 2 tvshows
//might need to dismiss spinner
//might need to pass menu to restorationhandler
//then restoreUserActivitystate is called on menuviewcontroller which should in turn call it on underlying vcs
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
return YES;
}
return NO;
}
- (void)application:(UIApplication *)application didFailToContinueUserActivityWithType:(NSString *)userActivityType error:(NSError *)error
{
if (error.code != NSUserCancelledError){
//TODO: present alert
}
}
- (void)pathMigrationToGroupsIfNeeded:(NSError **)migrationError
{
MLMediaLibrary *mediaLibrary = [MLMediaLibrary sharedMediaLibrary];
......
......@@ -115,37 +115,57 @@
<objects>
<controller identifier="nowPlaying" id="Mzo-Y8-gdK" customClass="VLCNowPlayingInterfaceController">
<items>
<label alignment="left" accessibilityLabel="title" text="title" textAlignment="left" numberOfLines="0" id="H58-Y8-Tbc"/>
<label alignment="left" accessibilityLabel="playback duration" text="duration" id="D0h-cq-wsv"/>
<separator alignment="left" id="po2-UB-p8C">
<color key="color" red="0.92549019610000005" green="0.43529411759999997" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</separator>
<button width="1" alignment="left" accessibilityLabel="play / pause" accessibilityHint="starts playing or pauses the current playback" title="playpause" id="BAZ-aC-ETt">
<connections>
<action selector="playPausePressed" destination="Mzo-Y8-gdK" id="6p8-JZ-0Gh"/>
</connections>
</button>
<group width="1" alignment="left" id="uwS-0S-Ag2">
<group width="1" height="1" alignment="left" layout="vertical" id="uwS-0S-Ag2">
<items>
<button width="0.5" alignment="left" accessibilityLabel="backward" title="&lt;&lt;" id="uKa-8V-C8x">
<connections>
<action selector="skipBackward" destination="Mzo-Y8-gdK" id="aP1-vb-XwF"/>
</connections>
</button>
<button width="0.5" alignment="left" accessibilityLabel="forward" title="&gt;&gt;" id="w8s-Mc-7oV">
<connections>
<action selector="skipForward" destination="Mzo-Y8-gdK" id="1kf-Nh-kjr"/>
</connections>
</button>
<group width="1" height="1" heightAdjustment="-20" alignment="left" id="iCs-yD-jsj">
<items>
<group width="1" widthAdjustment="-20" alignment="center" verticalAlignment="center" id="egl-IT-539">
<items>
<button alignment="left" verticalAlignment="center" accessibilityLabel="backward" backgroundImage="backward" id="uKa-8V-C8x">
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<action selector="skipBackward" destination="Mzo-Y8-gdK" id="aP1-vb-XwF"/>
</connections>
</button>
<button alignment="center" accessibilityLabel="play / pause" accessibilityHint="starts playing or pauses the current playback" backgroundImage="pause" id="BAZ-aC-ETt">
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<action selector="playPausePressed" destination="Mzo-Y8-gdK" id="6p8-JZ-0Gh"/>
</connections>
</button>
<button alignment="right" verticalAlignment="center" accessibilityLabel="forward" backgroundImage="forward" id="w8s-Mc-7oV">
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<action selector="skipForward" destination="Mzo-Y8-gdK" id="1kf-Nh-kjr"/>
</connections>
</button>
</items>
<variation key="device=watch42mm" widthAdjustment="-40"/>
</group>
</items>
</group>
<group width="1" alignment="left" verticalAlignment="bottom" id="d9m-EJ-n3r">
<items>
<label width="100" alignment="left" verticalAlignment="bottom" accessibilityLabel="title" text="title" id="H58-Y8-Tbc">
<fontDescription key="font" type="system" pointSize="14"/>
</label>
<label alignment="right" verticalAlignment="bottom" accessibilityLabel="playback duration" text="duration" id="D0h-cq-wsv">
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="font" style="UICTFontTextStyleFootnote"/>
</label>
</items>
</group>
<separator alignment="left" verticalAlignment="bottom" id="ZMm-LO-hqi">
<color key="color" red="0.92549019610000005" green="0.43529411759999997" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</separator>
</items>
</group>
<imageView width="1" alignment="center" contentMode="scaleAspectFill" id="3JI-SS-2Wb"/>
</items>
<connections>
<outlet property="durationLabel" destination="D0h-cq-wsv" id="3AN-YZ-yEj"/>
<outlet property="image" destination="3JI-SS-2Wb" id="rqC-Lb-tRt"/>
<outlet property="playElementsGroup" destination="uwS-0S-Ag2" id="ZmT-tX-Zza"/>
<outlet property="playPauseButton" destination="BAZ-aC-ETt" id="X17-bz-cFy"/>
<outlet property="progressSeparator" destination="po2-UB-p8C" id="sq9-AH-EhQ"/>
<outlet property="progressSeparator" destination="ZMm-LO-hqi" id="uHg-0Y-wlm"/>
<outlet property="titleLabel" destination="H58-Y8-Tbc" id="xZs-ZW-Shj"/>
</connections>
</controller>
......@@ -153,5 +173,5 @@
<point key="canvasLocation" x="221" y="605"/>
</scene>
</scenes>
<color key="tintColor" red="0.89803921568627454" green="0.38823529411764707" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="tintColor" red="0.92549019610000005" green="0.43529411759999997" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</document>
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "backward.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "forward.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "pause.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode",
"template-rendering-intent" : "original"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "play.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
#import <Foundation/Foundation.h>
@interface VLCNowPlayingInterfaceController : WKInterfaceController
@property (weak, nonatomic) IBOutlet WKInterfaceImage *image;
@property (weak, nonatomic) IBOutlet WKInterfaceGroup *playElementsGroup;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *titleLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *durationLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceButton *playPauseButton;
......
......@@ -20,6 +20,7 @@
@interface VLCNowPlayingInterfaceController ()
@property (nonatomic, copy) NSString *titleString;
@property (nonatomic, copy) NSNumber *playBackDurationNumber;
@property (nonatomic) BOOL isPlaying;
@end
@implementation VLCNowPlayingInterfaceController
......@@ -29,6 +30,7 @@
self = [super init];
if (self) {
[self setTitle:NSLocalizedString(@"PLAYING", nil)];
_isPlaying = YES;
}
return self;
}
......@@ -67,6 +69,7 @@
[self updateWithNowPlayingInfo:replyInfo[@"nowPlayingInfo"] andFile:file];
}];
}
- (void)updateWithNowPlayingInfo:(NSDictionary*)nowPlayingInfo andFile:(MLFile*)file {
self.titleString = file.title ?: nowPlayingInfo[MPMediaItemPropertyTitle];
......@@ -89,10 +92,14 @@
self.progressSeparator.width = noProgress ? 0.0 : progressWidth;
self.playBackDurationNumber = duration;
self.image.image = [VLCThumbnailsCache thumbnailForManagedObject:file];
CGFloat width = CGRectGetWidth([WKInterfaceDevice currentDevice].screenBounds);
CGFloat height = CGRectGetHeight([WKInterfaceDevice currentDevice].screenBounds);
UIImage *image = [VLCThumbnailsCache thumbnailForManagedObject:file toFitRect:CGRectMake(0, 0, width*2, height*2) shouldReplaceCache:NO];
[self.playElementsGroup setBackgroundImage:image];
}
- (IBAction)playPausePressed {
self.isPlaying = !self.isPlaying;
[WKInterfaceController openParentApplication:@{@"name": @"playpause"} reply:^(NSDictionary *replyInfo, NSError *error) {
NSLog(@"playpause %@",replyInfo);
}];
......@@ -111,18 +118,23 @@
}
- (void)setIsPlaying:(BOOL)isPlaying {
[self.playPauseButton setBackgroundImageNamed:isPlaying? @"pause":@"play"];
_isPlaying = isPlaying;
}
- (void)setTitleString:(NSString *)titleString {
if (![_titleString isEqualToString:titleString] || (_titleString==nil && titleString)) {
_titleString = [titleString copy];
self.titleLabel.text = titleString;
[self.titleLabel setText:titleString];
}
}
- (void)setPlayBackDurationNumber:(NSNumber *)playBackDurationNumber {
if (![_playBackDurationNumber isEqualToNumber:playBackDurationNumber] || (_playBackDurationNumber==nil && playBackDurationNumber)) {
_playBackDurationNumber = playBackDurationNumber;
self.durationLabel.text = [VLCTime timeWithNumber:playBackDurationNumber].stringValue;
[self.durationLabel setText:[VLCTime timeWithNumber:playBackDurationNumber].stringValue];
}
}
......
......@@ -281,6 +281,13 @@ typedef enum {
return objects;
}
- (void)setLibraryMode:(VLCLibraryMode)libraryMode
{
//should also handle diving into a folder
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode" userInfo:@{@"state" : @(self.libraryMode)} webpageURL:nil];
_libraryMode = libraryMode;
}
@end
......
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