mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +00:00
Use receiver application statusText instead of host:port when not idle
This commit is contained in:
@@ -24,7 +24,7 @@ class AppDelegate : NSObject, NSApplicationDelegate {
|
|||||||
// Decode and store initialization JSON data
|
// Decode and store initialization JSON data
|
||||||
self.initData = try JSONDecoder().decode(InitData.self, from: data)
|
self.initData = try JSONDecoder().decode(InitData.self, from: data)
|
||||||
} catch {
|
} catch {
|
||||||
fputs("Error: Failed to parse input data\n", stderr)
|
fputs("Error: Failed to parse input data\n (\(error))", stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,13 @@ class ReceiverView : NSStackView {
|
|||||||
|
|
||||||
self.receiver = receiver
|
self.receiver = receiver
|
||||||
|
|
||||||
|
let statusText = receiver.status.application.isIdleScreen
|
||||||
|
? "\(receiver.host):\(receiver.port)"
|
||||||
|
: receiver.status.application.statusText
|
||||||
|
|
||||||
let metaStackView = NSStackView(views: [
|
let metaStackView = NSStackView(views: [
|
||||||
makeLabel(receiver.friendlyName, size: 14)
|
makeLabel(receiver.friendlyName, size: 14)
|
||||||
, makeLabel("\(receiver.host):\(receiver.port)"
|
, makeLabel(statusText
|
||||||
, size: NSFont.smallSystemFontSize
|
, size: NSFont.smallSystemFontSize
|
||||||
, color: .secondaryLabelColor)
|
, color: .secondaryLabelColor)
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,6 +1,23 @@
|
|||||||
struct Receiver : Codable {
|
struct Receiver : Codable {
|
||||||
|
struct Status: Codable {
|
||||||
|
let application: Application
|
||||||
|
let volume: Volume
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Application: Codable {
|
||||||
|
let displayName: String
|
||||||
|
let isIdleScreen: Bool
|
||||||
|
let statusText: String
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Volume: Codable {
|
||||||
|
let level: Double
|
||||||
|
let muted: Bool
|
||||||
|
}
|
||||||
|
|
||||||
let friendlyName: String
|
let friendlyName: String
|
||||||
let host: String
|
let host: String
|
||||||
let id: String
|
let id: String
|
||||||
let port: Int
|
let port: Int
|
||||||
|
let status: Status
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,9 @@ export interface Receiver {
|
|||||||
export interface ReceiverStatus {
|
export interface ReceiverStatus {
|
||||||
application: {
|
application: {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
isIdleScreen: string;
|
isIdleScreen: boolean;
|
||||||
statusText: string;
|
statusText: string;
|
||||||
};
|
};
|
||||||
id: string;
|
|
||||||
volume: {
|
volume: {
|
||||||
level: number;
|
level: number;
|
||||||
muted: boolean
|
muted: boolean
|
||||||
|
|||||||
@@ -235,9 +235,10 @@ class ReceiverEntry extends Component<ReceiverEntryProps, ReceiverEntryState> {
|
|||||||
{ this.props.receiver.friendlyName }
|
{ this.props.receiver.friendlyName }
|
||||||
</div>
|
</div>
|
||||||
<div className="receiver-address">
|
<div className="receiver-address">
|
||||||
{ `${this.props.receiver.host}:${this.props.receiver.port}` }
|
{ this.props.receiver.status.application.isIdleScreen
|
||||||
|
? `${this.props.receiver.host}:${this.props.receiver.port}`
|
||||||
|
: this.props.receiver.status.application.statusText }
|
||||||
</div>
|
</div>
|
||||||
<div className="receiver-status"></div>
|
|
||||||
<button className="receiver-connect"
|
<button className="receiver-connect"
|
||||||
onClick={ this.handleCast }
|
onClick={ this.handleCast }
|
||||||
disabled={this.props.isLoading}>
|
disabled={this.props.isLoading}>
|
||||||
|
|||||||
Reference in New Issue
Block a user