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