Commit b80de18f authored by Tobias's avatar Tobias Committed by Felix Paul Kühne

show (static) playback progress by (mis)using separators filled with color

parent 25350b9b
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="7528.3" systemVersion="14C1514" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="AgC-eL-Hgc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="AgC-eL-Hgc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="3737"/>
</dependencies>
<scenes>
......@@ -19,16 +19,20 @@
<table alignment="left" id="lC4-Vd-sgP">
<items>
<tableRow identifier="mediaRow" id="QhF-se-FCS" customClass="VLCRowController">
<group key="rootItem" width="1" height="60" alignment="left" contentMode="scaleAspectFill" radius="5" id="IQK-uE-8Jr">
<group key="rootItem" width="1" height="60" alignment="left" contentMode="scaleAspectFill" layout="vertical" radius="5" id="IQK-uE-8Jr">
<items>
<label alignment="left" verticalAlignment="bottom" text="title" minimumScaleFactor="0.90000000000000002" id="bUB-PE-2P0">
<label alignment="left" text="title" minimumScaleFactor="0.90000000000000002" id="bUB-PE-2P0">
<fontDescription key="font" style="UICTFontTextStyleCaption2"/>
</label>
<separator alignment="left" verticalAlignment="bottom" id="ziJ-iW-Rvc">
<color key="color" red="0.92549019610000005" green="0.43529411759999997" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</separator>
</items>
<color key="backgroundColor" red="0.76862745099999996" green="0.74901960779999999" blue="0.75686274509999996" alpha="1" colorSpace="calibratedRGB"/>
</group>
<connections>
<outlet property="group" destination="IQK-uE-8Jr" id="AMK-in-WKm"/>
<outlet property="progressSeparator" destination="ziJ-iW-Rvc" id="1Ue-rT-1D9"/>
<outlet property="titleLabel" destination="bUB-PE-2P0" id="U07-pL-M8k"/>
</connections>
</tableRow>
......@@ -103,6 +107,7 @@
<outlet property="durationLabel" destination="eqY-Zs-PAu" id="ttj-gB-C2S"/>
<outlet property="group" destination="w46-UP-k21" id="tq6-TE-A5x"/>
<outlet property="playNowButton" destination="4LT-2D-Zeq" id="d2T-jc-gAb"/>
<outlet property="progressSeparator" destination="sMd-Gr-vD4" id="ly1-6A-yhJ"/>
<outlet property="titleLabel" destination="0av-IS-YI5" id="vEh-KH-Vt5"/>
</connections>
</controller>
......@@ -116,6 +121,9 @@
<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"/>
......@@ -141,6 +149,7 @@
<outlet property="durationLabel" destination="D0h-cq-wsv" id="3AN-YZ-yEj"/>
<outlet property="image" destination="3JI-SS-2Wb" id="rqC-Lb-tRt"/>
<outlet property="playPauseButton" destination="BAZ-aC-ETt" id="X17-bz-cFy"/>
<outlet property="progressSeparator" destination="po2-UB-p8C" id="sq9-AH-EhQ"/>
<outlet property="titleLabel" destination="H58-Y8-Tbc" id="xZs-ZW-Shj"/>
</connections>
</controller>
......
......@@ -19,6 +19,7 @@
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *durationLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceButton *playNowButton;
@property (weak, nonatomic) IBOutlet WKInterfaceGroup *group;
@property (weak, nonatomic) IBOutlet WKInterfaceSeparator *progressSeparator;
- (IBAction)playNow;
@end
......@@ -16,7 +16,7 @@
#import "VLCThumbnailsCache.h"
@interface VLCDetailInterfaceController ()
@property (nonatomic, weak) NSManagedObject *file;
@property (nonatomic, weak) NSManagedObject *managedObject;
@end
@implementation VLCDetailInterfaceController
......@@ -49,31 +49,39 @@
[super didDeactivate];
}
- (void)configureWithFile:(NSManagedObject *)file {
self.file = file;
if ([file isKindOfClass:[MLShowEpisode class]]) {
[self.titleLabel setText:((MLShowEpisode *)file).name];
} else if ([file isKindOfClass:[MLFile class]]) {
self.durationLabel.text = [VLCTime timeWithNumber:((MLFile *)file).duration].stringValue;
- (void)configureWithFile:(NSManagedObject *)managedObject {
self.managedObject = managedObject;
float playbackProgress = 0.0;
if ([managedObject isKindOfClass:[MLShowEpisode class]]) {
[self.titleLabel setText:((MLShowEpisode *)managedObject).name];
} else if ([managedObject isKindOfClass:[MLFile class]]) {
MLFile *file = (MLFile *)managedObject;
self.durationLabel.text = [VLCTime timeWithNumber:file.duration].stringValue;
playbackProgress = file.lastPosition.floatValue;
[self.titleLabel setText:((MLFile *)file).title];
} else if ([file isKindOfClass:[MLAlbumTrack class]]) {
[self.titleLabel setText:((MLAlbumTrack *)file).title];
} else if ([managedObject isKindOfClass:[MLAlbumTrack class]]) {
[self.titleLabel setText:((MLAlbumTrack *)managedObject).title];
} else {
NSAssert(NO, @"check what filetype we try to show here and add it above");
}
BOOL playEnabled = file != nil;
BOOL playEnabled = managedObject != nil;
self.playNowButton.enabled = playEnabled;
UIImage *thumbnail = [VLCThumbnailsCache thumbnailForManagedObject:file];
UIImage *thumbnail = [VLCThumbnailsCache thumbnailForManagedObject:managedObject];
if (thumbnail) {
[self.group setBackgroundImage:thumbnail];
}
BOOL noProgress = (playbackProgress == 0.0 || playbackProgress == 1.0);
self.progressSeparator.hidden = noProgress;
self.progressSeparator.width = floor(playbackProgress * CGRectGetWidth([WKInterfaceDevice currentDevice].screenBounds));
}
- (IBAction)playNow {
NSDictionary *dict = @{@"name":@"playFile",
@"userInfo":@{
@"URIRepresentation": self.file.objectID.URIRepresentation.absoluteString,
@"URIRepresentation": self.managedObject.objectID.URIRepresentation.absoluteString,
}
};
[WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
......
......@@ -18,6 +18,7 @@
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *titleLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *durationLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceButton *playPauseButton;
@property (weak, nonatomic) IBOutlet WKInterfaceSeparator *progressSeparator;
- (IBAction)playPausePressed;
- (IBAction)skipForward;
......
......@@ -72,9 +72,22 @@
NSNumber *duration = file.duration;
if (!duration) {
duration = nowPlayingInfo[MPMediaItemPropertyPlaybackDuration];
float durationFloat = duration.floatValue;
duration = @(durationFloat*1000);
}
NSNumber *playbackTime = nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime];
float playbackProgress = 0.0;
float playbackTimeFloat = playbackTime.floatValue; // seconds
float durationFloat = duration.floatValue; // milliseconds
if (playbackTimeFloat > 0.0 && durationFloat > 0.0) {
playbackProgress = playbackTimeFloat / (durationFloat/1000);
}
BOOL noProgress = (playbackProgress == 0.0 || playbackProgress == 1.0);
CGFloat progressWidth = floor(playbackProgress * CGRectGetWidth([WKInterfaceDevice currentDevice].screenBounds));;
self.progressSeparator.width = noProgress ? 0.0 : progressWidth;
self.playBackDurationNumber = duration;
self.image.image = [VLCThumbnailsCache thumbnailForManagedObject:file];
}
......
......@@ -24,7 +24,6 @@
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *emptyLibraryLabel;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *emptyLibraryLabelLong;
- (IBAction)previousPagePressed;
- (IBAction)nextPagePressed;
......
......@@ -161,6 +161,7 @@ typedef enum {
VLCRowController *row = rowController;
UIImage *backgroundImage = [VLCThumbnailsCache thumbnailForManagedObject:storageObject];
float playbackProgress = 0.0;
if ([storageObject isKindOfClass:[MLShow class]]) {
row.titleLabel.text = ((MLAlbum *)storageObject).name;
} else if ([storageObject isKindOfClass:[MLShowEpisode class]]) {
......@@ -171,10 +172,16 @@ typedef enum {
row.titleLabel.text = ((MLAlbum *)storageObject).name;
} else if ([storageObject isKindOfClass:[MLAlbumTrack class]]) {
row.titleLabel.text = ((MLAlbumTrack *)storageObject).title;
} else {
row.titleLabel.text = [(MLFile *)storageObject title];
} else if ([storageObject isKindOfClass:[MLFile class]]){
MLFile *file = (MLFile *)storageObject;
row.titleLabel.text = [file title];
playbackProgress = file.lastPosition.floatValue;
}
BOOL noProgress = (playbackProgress == 0.0 || playbackProgress == 1.0);
row.progressSeparator.hidden = noProgress;
row.progressSeparator.width = floor(playbackProgress * CGRectGetWidth([WKInterfaceDevice currentDevice].screenBounds));
/* FIXME: add placeholder image once designed
if (backgroundImage == nil)
backgroundImage = nil;
......
......@@ -14,4 +14,6 @@
@interface VLCRowController : NSObject
@property (nonatomic, weak) IBOutlet WKInterfaceLabel *titleLabel;
@property (nonatomic, weak) IBOutlet WKInterfaceGroup *group;
@property (nonatomic, weak) IBOutlet WKInterfaceSeparator *progressSeparator;
@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