11import 'dart:async' ;
22
33import 'package:basic_utils/basic_utils.dart' ;
4- import 'package:media_kit/media_kit.dart' ;
54import 'package:radio_browser_api/radio_browser_api.dart' ;
65
76import '../common/data/audio.dart' ;
@@ -10,6 +9,7 @@ import '../common/data/mpv_meta_data.dart';
109import '../common/logging.dart' ;
1110import '../expose/expose_service.dart' ;
1211import '../extensions/string_x.dart' ;
12+ import '../player/observe_property_io.dart' ;
1313import '../player/player_service.dart' ;
1414import 'online_art_service.dart' ;
1515
@@ -35,9 +35,10 @@ class RadioService {
3535
3636 Future <void > init ({bool observePlayer = true }) async {
3737 if (observePlayer) {
38- await (_playerService.player.platform as NativePlayer ).observeProperty (
39- 'metadata' ,
40- _onMpvMetadata,
38+ await observeProperty (
39+ property: 'metadata' ,
40+ player: _playerService.player,
41+ listener: _onMpvMetadata,
4142 );
4243 }
4344
@@ -262,9 +263,8 @@ class RadioService {
262263
263264 Future <void > dispose () async {
264265 await _propertiesChangedController.close ();
265- await (_playerService.player.platform as NativePlayer ).unobserveProperty (
266- 'metadata' ,
267- );
266+
267+ await observeProperty (property: 'metadata' , player: _playerService.player);
268268 }
269269
270270 //
@@ -279,8 +279,7 @@ class RadioService {
279279 }
280280
281281 Future <void > _onMpvMetadata (data) async {
282- if (_playerService.audio? .audioType != AudioType .radio ||
283- ! data.contains ('icy-title' )) {
282+ if (! data.contains ('icy-title' )) {
284283 return ;
285284 }
286285 final newData = MpvMetaData .fromJson (data);
0 commit comments