mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Adds a slider control that shows the track playback progress. The slider can be used to seek through the track.
29 lines
586 B
Swift
29 lines
586 B
Swift
//
|
|
// 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))!
|
|
}
|
|
}
|