mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Elapsed time counts up
This commit is contained in:
parent
212565ccd4
commit
ad837e8cb2
@ -18,6 +18,7 @@
|
||||
E408D3C2220E134F0006D9BE /* AlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E408D3C1220E134F0006D9BE /* AlbumViewController.swift */; };
|
||||
E408D3CA220E341D0006D9BE /* AlbumItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E408D3C8220E341D0006D9BE /* AlbumItem.swift */; };
|
||||
E408D3CB220E341D0006D9BE /* AlbumItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = E408D3C9220E341D0006D9BE /* AlbumItem.xib */; };
|
||||
E40FE71E221C385000A4223F /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = E40FE71D221C385000A4223F /* Time.swift */; };
|
||||
E41B22C021FB6BBA00D544F6 /* libmpdclient.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */; settings = {ATTRIBUTES = (Required, ); }; };
|
||||
E41B22C121FB6C3300D544F6 /* libmpdclient.2.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
E41B22C621FB932700D544F6 /* MPDClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41B22C521FB932700D544F6 /* MPDClient.swift */; };
|
||||
@ -82,6 +83,7 @@
|
||||
E408D3C1220E134F0006D9BE /* AlbumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumViewController.swift; sourceTree = "<group>"; };
|
||||
E408D3C8220E341D0006D9BE /* AlbumItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumItem.swift; sourceTree = "<group>"; };
|
||||
E408D3C9220E341D0006D9BE /* AlbumItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlbumItem.xib; sourceTree = "<group>"; };
|
||||
E40FE71D221C385000A4223F /* Time.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Time.swift; sourceTree = "<group>"; };
|
||||
E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libmpdclient.2.dylib; path = libmpdclient/output/libmpdclient.2.dylib; sourceTree = "<group>"; };
|
||||
E41B22C421FB715A00D544F6 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
|
||||
E41B22C521FB932700D544F6 /* MPDClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPDClient.swift; sourceTree = "<group>"; };
|
||||
@ -181,6 +183,7 @@
|
||||
E407861A2110CE6E006887B1 /* Persephone */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E40FE71C221C384200A4223F /* Models */,
|
||||
E407861F2110CE70006887B1 /* Assets.xcassets */,
|
||||
E408D3B7220DE8CC0006D9BE /* Extensions */,
|
||||
E4D1B598220BA3C90026F233 /* Resources */,
|
||||
@ -239,6 +242,14 @@
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E40FE71C221C384200A4223F /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E40FE71D221C385000A4223F /* Time.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E41B22BE21FB6B3300D544F6 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -493,6 +504,7 @@
|
||||
E4A642DA22090CBE00067D21 /* Status.swift in Sources */,
|
||||
E4E8CC942206097F0024217A /* NotificationsController.swift in Sources */,
|
||||
E408D3B6220DD8970006D9BE /* Notification.swift in Sources */,
|
||||
E40FE71E221C385000A4223F /* Time.swift in Sources */,
|
||||
E408D3B9220DE98F0006D9BE /* NSUserInterfaceItemIdentifier.swift in Sources */,
|
||||
E4EB2379220F10B8008C70C0 /* Pair.swift in Sources */,
|
||||
E465049A21E94DF500A70F4C /* WindowController.swift in Sources */,
|
||||
|
||||
@ -82,6 +82,7 @@ class WindowController: NSWindowController {
|
||||
|
||||
trackProgressBar.maxValue = Double(totalTime * 1000)
|
||||
trackProgressBar.integerValue = Int(elapsedTimeMs)
|
||||
setTimeElapsed()
|
||||
|
||||
trackProgressBar.isEnabled = [.playing, .paused].contains(state)
|
||||
|
||||
@ -106,6 +107,15 @@ class WindowController: NSWindowController {
|
||||
elapsedTimeMs = currentProgress + 250
|
||||
|
||||
trackProgressBar.integerValue = Int(elapsedTimeMs!)
|
||||
setTimeElapsed()
|
||||
}
|
||||
|
||||
func setTimeElapsed() {
|
||||
guard let elapsedTimeMs = elapsedTimeMs else { return }
|
||||
|
||||
let time = Time(timeInSeconds: Int(elapsedTimeMs) / 1000)
|
||||
|
||||
trackProgress.stringValue = time.formattedTime
|
||||
}
|
||||
|
||||
@IBAction func handleTransportControl(_ sender: NSSegmentedControl) {
|
||||
|
||||
28
Persephone/Models/Time.swift
Normal file
28
Persephone/Models/Time.swift
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Time.swift
|
||||
// Persephone
|
||||
//
|
||||
// Created by Daniel Barber on 2019/2/19.
|
||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Time {
|
||||
let timeInSeconds: Int
|
||||
|
||||
var formattedTime: String {
|
||||
let formatter = DateComponentsFormatter()
|
||||
|
||||
if timeInSeconds >= 3600 {
|
||||
formatter.allowedUnits = [.second, .minute, .hour]
|
||||
} else {
|
||||
formatter.allowedUnits = [.second, .minute]
|
||||
}
|
||||
|
||||
formatter.zeroFormattingBehavior = .pad
|
||||
formatter.unitsStyle = .positional
|
||||
|
||||
return formatter.string(from: TimeInterval(timeInSeconds))!
|
||||
}
|
||||
}
|
||||
@ -142,10 +142,10 @@
|
||||
<toolbarItem implicitItemIdentifier="D72AC4FE-1D0A-420A-8EA8-F28DBFCE9A8E" explicitItemIdentifier="trackProgress" label="Track progress" paletteLabel="Track progress" sizingBehavior="auto" id="n52-8S-6kR">
|
||||
<nil key="toolTip"/>
|
||||
<textField key="view" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="kx6-xm-TAN">
|
||||
<rect key="frame" x="20" y="14" width="47" height="17"/>
|
||||
<rect key="frame" x="14" y="14" width="59" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" placeholderString="00:00" id="g0c-k5-wCA">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
@ -167,7 +167,7 @@
|
||||
<rect key="frame" x="20" y="14" width="52" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" placeholderString="-00:00" id="XUa-pD-s5c">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user