Skip to content

Commit 2a9ca4e

Browse files
committed
Formatting and nullability.
1 parent e8c4c42 commit 2a9ca4e

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

audio_service/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ dependencies:
3131
# path: audio_service_web
3232

3333
# Use these deps when publishing.
34-
audio_service_platform_interface: ^0.1.2
35-
audio_service_web: ^0.1.3
34+
audio_service_platform_interface: ^0.1.3
35+
audio_service_web: ^0.1.4
3636

3737
audio_session: ^0.1.20
3838
rxdart: '>=0.26.0 <0.29.0'

audio_service_web/lib/audio_service_web.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class AudioServiceWeb extends AudioServicePlatform {
1717
web.MediaSession get _mediaSession => web.window.navigator.mediaSession;
1818

1919
final _mediaSessionSupported = _SupportChecker(
20-
() => js.globalContext.hasProperty('MediaSession'.toJS).toDart,
20+
() => js.globalContext.hasProperty('MediaSession'.toJS).toDart,
2121
"MediaSession is not supported in this browser, so plugin is no-op",
2222
);
2323
final _setPositionStateSupported = _SupportChecker(
24-
() => web.window.navigator.mediaSession
24+
() => web.window.navigator.mediaSession
2525
.hasProperty('setPositionState'.toJS)
2626
.toDart,
2727
"MediaSession.setPositionState is not supported in this browser",
@@ -112,7 +112,7 @@ class AudioServiceWeb extends AudioServicePlatform {
112112
);
113113
break;
114114
default:
115-
// no-op
115+
// no-op
116116
break;
117117
}
118118
}
@@ -125,13 +125,13 @@ class AudioServiceWeb extends AudioServicePlatform {
125125
((MediaSessionActionDetails details) {
126126
// Browsers use seconds
127127
handlerCallbacks?.seek(SeekRequest(
128-
position:
129-
Duration(milliseconds: (details.seekTime * 1000).round()),
128+
position: Duration(
129+
milliseconds: (details.seekTime! * 1000).round()),
130130
));
131131
}).toJS);
132132
break;
133133
default:
134-
// no-op
134+
// no-op
135135
break;
136136
}
137137
}
@@ -164,17 +164,18 @@ class AudioServiceWeb extends AudioServicePlatform {
164164
return;
165165
}
166166
mediaItem = request.mediaItem;
167-
final artist = mediaItem!.artist;
168-
final album = mediaItem!.album;
167+
final artist = mediaItem!.artist ?? '';
168+
final album = mediaItem!.album ?? '';
169169
final artUri = mediaItem!.artUri;
170170

171171
_mediaSession.metadata = web.MediaMetadata(
172172
web.MediaMetadataInit(
173173
title: mediaItem!.title,
174-
artist: artist.toString(),
175-
album: album.toString(),
174+
artist: artist,
175+
album: album,
176176
artwork: [
177-
web.MediaImage(src: artUri.toString(), sizes: '512x512'),
177+
if (artUri != null)
178+
web.MediaImage(src: artUri.toString(), sizes: '512x512'),
178179
].toJS,
179180
),
180181
);

audio_service_web/lib/js/media_session_web.dart

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
library media_session_web;
88

99
import 'dart:js_interop';
10-
import 'package:web/web.dart' as web;
1110

1211
/// Media session playback state types.
1312
///
@@ -54,41 +53,41 @@ typedef MediaSessionActionHandler = dynamic Function(MediaSessionActionDetails);
5453
@JS()
5554
@anonymous
5655
extension type MediaSessionActionDetails._(JSObject _) implements JSObject {
57-
/// An action type string taken from the [MediaActions], indicating which
58-
/// type of action needs to be performed.
59-
external String get action;
56+
/// An action type string taken from the [MediaActions], indicating which
57+
/// type of action needs to be performed.
58+
external String get action;
6059

61-
/// Indicates whether or not to perform a "fast" seek.
62-
///
63-
/// A `seekto` action may optionally include this property.
64-
///
65-
/// A "fast" seek is a seek being performed in a rapid sequence, such as when
66-
/// fast-forwarding or reversing through the media, rapidly skipping through it.
67-
///
68-
/// This property can be used to indicate that you should use the shortest possible
69-
/// method to seek the media. This property is not included on the final action in
70-
/// the seek sequence in this situation.
71-
external bool get fastSeek;
60+
/// Indicates whether or not to perform a "fast" seek.
61+
///
62+
/// A `seekto` action may optionally include this property.
63+
///
64+
/// A "fast" seek is a seek being performed in a rapid sequence, such as when
65+
/// fast-forwarding or reversing through the media, rapidly skipping through it.
66+
///
67+
/// This property can be used to indicate that you should use the shortest possible
68+
/// method to seek the media. This property is not included on the final action in
69+
/// the seek sequence in this situation.
70+
external bool? get fastSeek;
7271

73-
/// If the action is either `seekforward` or `seekbackward`
74-
/// and this property is present, it is a floating point value which indicates
75-
/// the seek interval.
76-
///
77-
/// If this property isn't present, those actions should choose a reasonable
78-
/// default interval.
79-
external double get seekOffset;
72+
/// If the action is either `seekforward` or `seekbackward`
73+
/// and this property is present, it is a floating point value which indicates
74+
/// the seek interval.
75+
///
76+
/// If this property isn't present, those actions should choose a reasonable
77+
/// default interval.
78+
external double? get seekOffset;
8079

81-
/// If the action is `seekto`, this property is present and
82-
/// indicates the absolute time within the media to move the playback position to.
83-
///
84-
/// This property is not present for other action types.
85-
external double get seekTime;
80+
/// If the action is `seekto`, this property is present and
81+
/// indicates the absolute time within the media to move the playback position to.
82+
///
83+
/// This property is not present for other action types.
84+
external double? get seekTime;
8685

87-
/// Creates the details.
88-
external factory MediaSessionActionDetails({
89-
String? action,
90-
bool? fastSeek,
91-
double? seekOffset,
92-
double? seekTime,
93-
});
86+
/// Creates the details.
87+
external factory MediaSessionActionDetails({
88+
String? action,
89+
bool? fastSeek,
90+
double? seekOffset,
91+
double? seekTime,
92+
});
9493
}

audio_service_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: audio_service_web
22
description: Web platform implementation of audio_service. This implementation is endorsed and therefore doesn't require a direct dependency.
3-
version: 0.1.3
3+
version: 0.1.4
44
homepage: https://github.com/ryanheise/audio_service/tree/master/audio_service_web
55

66
environment:

0 commit comments

Comments
 (0)