ocarina2/lib/api/subsonic/song.dart

46 lines
1.2 KiB
Dart
Raw Normal View History

2024-05-23 19:14:08 +02:00
import 'package:json_annotation/json_annotation.dart';
import 'package:ocarina/api/subsonic/subsonic.dart';
part 'song.g.dart';
@JsonSerializable()
class Song {
Song({
required this.id,
required this.artistName,
required this.title,
required this.albumName,
required this.albumId,
required this.artistId,
required this.duration,
required this.bitRate,
required this.contentType,
required this.fileType,
2024-05-24 00:10:11 +02:00
required this.coverArtId,
2024-05-23 19:14:08 +02:00
this.trackNumber,
2024-05-24 00:10:11 +02:00
});
2024-05-23 19:14:08 +02:00
factory Song.fromJson(Map<String, dynamic> json) => _$SongFromJson(json);
Map<String, dynamic> toJson() => _$SongToJson(this);
final String id;
@JsonKey(name: "artist")
final String artistName;
2024-05-24 00:10:11 +02:00
final String? artistId;
2024-05-23 19:14:08 +02:00
final String albumId;
final String title;
@JsonKey(name: "album")
final String albumName;
@JsonKey(name: "track")
final int? trackNumber;
final int duration;
final int bitRate;
final String contentType;
@JsonKey(name: "suffix")
final String fileType;
@JsonKey(name: "coverArt")
2024-05-24 00:10:11 +02:00
final String coverArtId;
2024-05-23 19:14:08 +02:00
2024-05-24 00:10:11 +02:00
String get coverArtUrl => SubsonicApiService().getCoverArtUrl(coverArtId);
2024-05-23 19:14:08 +02:00
String get streamUrl => SubsonicApiService().getStreamUrl(id);
}