jellyflood/Shared/Extensions/JellyfinAPI/SessionInfo.swift
Joe 50e0cfef73
[iOS] Admin Dashboard - Active Devices Icons (#1275)
* Add Device images & Reference using the Enum as a filler if the NowPlayingItem is Nil

* Localize DeviceTypes.DisplayTitles

* Review changes. Last potential TODO: Image: ImageResource might not be the correct format

* DeviceType is needed to build tvOS

* Mirror Jellyfin-Blue-Blob for SVG configuration. Use ImageResource for the Device/Client Images

* Merge missing }

* Don't recreate the ImageResource since it's already generated.

* New webOS logo! Fix tvOS not having the new logos

* use if let, implicit self

* use secondary system fill for other

---------

Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
2024-10-15 21:34:38 -06:00

45 lines
1.3 KiB
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//
import Foundation
import JellyfinAPI
extension SessionInfo {
var device: DeviceType {
DeviceType(
client: client,
deviceName: deviceName
)
}
var playMethodDisplayTitle: String? {
guard nowPlayingItem != nil, let playState, let playMethod = playState.playMethod else { return nil }
if let transcodingInfo {
let isVideoDirect = transcodingInfo.isVideoDirect ?? false
let hasVideoCodec = transcodingInfo.videoCodec != nil
let isAudioDirect = transcodingInfo.isAudioDirect ?? false
if isVideoDirect || hasVideoCodec, isAudioDirect {
return L10n.remux
} else if isVideoDirect {
return PlayMethod.directStream.displayTitle
}
}
switch playMethod {
case .transcode:
return PlayMethod.transcode.displayTitle
case .directPlay, .directStream:
return PlayMethod.directPlay.displayTitle
}
}
}