additional carplay changes
This commit is contained in:
@@ -57,7 +57,9 @@ class CarPlayBridge {
|
|||||||
case 'getStateSnapshot':
|
case 'getStateSnapshot':
|
||||||
return _snapshot();
|
return _snapshot();
|
||||||
default:
|
default:
|
||||||
throw MissingPluginException('Unknown CarPlay bridge method: ${call.method}');
|
throw MissingPluginException(
|
||||||
|
'Unknown CarPlay bridge method: ${call.method}',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-21
@@ -18,7 +18,8 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
|
|
||||||
static const String streamUrl = 'https://kryz.out.airtime.pro/kryz_a';
|
static const String streamUrl = 'https://kryz.out.airtime.pro/kryz_a';
|
||||||
static const String mediaId = 'kryz-live-stream';
|
static const String mediaId = 'kryz-live-stream';
|
||||||
static const String _liveInfoEndpoint = 'http://kryz.airtime.pro/api/live-info';
|
static const String _liveInfoEndpoint =
|
||||||
|
'http://kryz.airtime.pro/api/live-info';
|
||||||
static const Duration _liveInfoTimeout = Duration(seconds: 8);
|
static const Duration _liveInfoTimeout = Duration(seconds: 8);
|
||||||
static const Duration _metadataRefreshInterval = Duration(seconds: 20);
|
static const Duration _metadataRefreshInterval = Duration(seconds: 20);
|
||||||
|
|
||||||
@@ -27,10 +28,7 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
title: 'KRYZ Live Stream',
|
title: 'KRYZ Live Stream',
|
||||||
artist: 'KRYZ Radio',
|
artist: 'KRYZ Radio',
|
||||||
album: 'Live',
|
album: 'Live',
|
||||||
extras: <String, dynamic>{
|
extras: <String, dynamic>{'isLive': true, 'seekable': false},
|
||||||
'isLive': true,
|
|
||||||
'seekable': false,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final AudioPlayer _player = AudioPlayer();
|
final AudioPlayer _player = AudioPlayer();
|
||||||
@@ -82,10 +80,7 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
try {
|
try {
|
||||||
if (!_isSourceLoaded) {
|
if (!_isSourceLoaded) {
|
||||||
await _player.setAudioSource(
|
await _player.setAudioSource(
|
||||||
AudioSource.uri(
|
AudioSource.uri(Uri.parse(streamUrl), tag: mediaItem.value),
|
||||||
Uri.parse(streamUrl),
|
|
||||||
tag: mediaItem.value,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
_isSourceLoaded = true;
|
_isSourceLoaded = true;
|
||||||
}
|
}
|
||||||
@@ -165,25 +160,35 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onPlayerStateChanged(PlayerState state) {
|
void _onPlayerStateChanged(PlayerState state) {
|
||||||
final AudioProcessingState processingState = switch (state.processingState) {
|
final AudioProcessingState processingState =
|
||||||
ProcessingState.idle => AudioProcessingState.idle,
|
switch (state.processingState) {
|
||||||
ProcessingState.loading => AudioProcessingState.loading,
|
ProcessingState.idle => AudioProcessingState.idle,
|
||||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
ProcessingState.loading => AudioProcessingState.loading,
|
||||||
ProcessingState.ready => AudioProcessingState.ready,
|
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||||
ProcessingState.completed => AudioProcessingState.completed,
|
ProcessingState.ready => AudioProcessingState.ready,
|
||||||
};
|
ProcessingState.completed => AudioProcessingState.completed,
|
||||||
|
};
|
||||||
|
|
||||||
final bool isPlaying = state.playing && state.processingState == ProcessingState.ready;
|
final bool isPlaying =
|
||||||
final bool isBuffering = (state.playing && state.processingState != ProcessingState.ready) ||
|
state.playing && state.processingState == ProcessingState.ready;
|
||||||
(_playRequested && !state.playing && state.processingState != ProcessingState.completed);
|
final bool isBuffering =
|
||||||
|
(state.playing && state.processingState != ProcessingState.ready) ||
|
||||||
|
(_playRequested &&
|
||||||
|
!state.playing &&
|
||||||
|
state.processingState != ProcessingState.completed);
|
||||||
|
|
||||||
playbackState.add(
|
playbackState.add(
|
||||||
playbackState.value.copyWith(
|
playbackState.value.copyWith(
|
||||||
controls: <MediaControl>[
|
controls: <MediaControl>[
|
||||||
if (isPlaying || isBuffering) MediaControl.stop else MediaControl.play,
|
if (isPlaying || isBuffering)
|
||||||
|
MediaControl.stop
|
||||||
|
else
|
||||||
|
MediaControl.play,
|
||||||
],
|
],
|
||||||
systemActions: const <MediaAction>{},
|
systemActions: const <MediaAction>{},
|
||||||
processingState: isBuffering ? AudioProcessingState.buffering : processingState,
|
processingState: isBuffering
|
||||||
|
? AudioProcessingState.buffering
|
||||||
|
: processingState,
|
||||||
playing: isPlaying,
|
playing: isPlaying,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-2
@@ -462,8 +462,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
label: const Text('Stop'),
|
label: const Text('Stop'),
|
||||||
),
|
),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
onPressed:
|
onPressed: _casting.status == CastingStatus.connecting
|
||||||
_casting.status == CastingStatus.connecting
|
|
||||||
? null
|
? null
|
||||||
: _toggleCasting,
|
: _toggleCasting,
|
||||||
icon: Icon(_castingIcon()),
|
icon: Icon(_castingIcon()),
|
||||||
|
|||||||
Reference in New Issue
Block a user