mirror of
https://github.com/Dummi26/musicdb.git
synced 2025-12-14 11:56:16 +01:00
add ways to modify tags, and add a Fav button to client
This commit is contained in:
@@ -359,6 +359,96 @@ impl Database {
|
||||
Command::RemoveArtist(artist) => {
|
||||
_ = self.remove_artist(artist);
|
||||
}
|
||||
Command::TagSongFlagSet(id, tag) => {
|
||||
if let Some(v) = self.get_song_mut(&id) {
|
||||
if !v.general.tags.contains(&tag) {
|
||||
v.general.tags.push(tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagSongFlagUnset(id, tag) => {
|
||||
if let Some(v) = self.get_song_mut(&id) {
|
||||
if let Some(i) = v.general.tags.iter().position(|v| v == &tag) {
|
||||
v.general.tags.remove(i);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagAlbumFlagSet(id, tag) => {
|
||||
if let Some(v) = self.albums.get_mut(&id) {
|
||||
if !v.general.tags.contains(&tag) {
|
||||
v.general.tags.push(tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagAlbumFlagUnset(id, tag) => {
|
||||
if let Some(v) = self.albums.get_mut(&id) {
|
||||
if let Some(i) = v.general.tags.iter().position(|v| v == &tag) {
|
||||
v.general.tags.remove(i);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagArtistFlagSet(id, tag) => {
|
||||
if let Some(v) = self.artists.get_mut(&id) {
|
||||
if !v.general.tags.contains(&tag) {
|
||||
v.general.tags.push(tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagArtistFlagUnset(id, tag) => {
|
||||
if let Some(v) = self.artists.get_mut(&id) {
|
||||
if let Some(i) = v.general.tags.iter().position(|v| v == &tag) {
|
||||
v.general.tags.remove(i);
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::TagSongPropertySet(id, key, val) => {
|
||||
if let Some(v) = self.get_song_mut(&id) {
|
||||
let new = format!("{key}{val}");
|
||||
if let Some(v) = v.general.tags.iter_mut().find(|v| v.starts_with(&key)) {
|
||||
*v = new;
|
||||
} else {
|
||||
v.general.tags.push(new);
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::TagSongPropertyUnset(id, key) => {
|
||||
if let Some(v) = self.get_song_mut(&id) {
|
||||
let tags = std::mem::replace(&mut v.general.tags, vec![]);
|
||||
v.general.tags = tags.into_iter().filter(|v| !v.starts_with(&key)).collect();
|
||||
}
|
||||
}
|
||||
Command::TagAlbumPropertySet(id, key, val) => {
|
||||
if let Some(v) = self.albums.get_mut(&id) {
|
||||
let new = format!("{key}{val}");
|
||||
if let Some(v) = v.general.tags.iter_mut().find(|v| v.starts_with(&key)) {
|
||||
*v = new;
|
||||
} else {
|
||||
v.general.tags.push(new);
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::TagAlbumPropertyUnset(id, key) => {
|
||||
if let Some(v) = self.albums.get_mut(&id) {
|
||||
let tags = std::mem::replace(&mut v.general.tags, vec![]);
|
||||
v.general.tags = tags.into_iter().filter(|v| !v.starts_with(&key)).collect();
|
||||
}
|
||||
}
|
||||
Command::TagArtistPropertySet(id, key, val) => {
|
||||
if let Some(v) = self.artists.get_mut(&id) {
|
||||
let new = format!("{key}{val}");
|
||||
if let Some(v) = v.general.tags.iter_mut().find(|v| v.starts_with(&key)) {
|
||||
*v = new;
|
||||
} else {
|
||||
v.general.tags.push(new);
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::TagArtistPropertyUnset(id, key) => {
|
||||
if let Some(v) = self.artists.get_mut(&id) {
|
||||
let tags = std::mem::replace(&mut v.general.tags, vec![]);
|
||||
v.general.tags = tags.into_iter().filter(|v| !v.starts_with(&key)).collect();
|
||||
}
|
||||
}
|
||||
Command::SetSongDuration(id, duration) => {
|
||||
if let Some(song) = self.get_song_mut(&id) {
|
||||
song.duration_millis = duration;
|
||||
|
||||
@@ -31,7 +31,6 @@ pub enum Command {
|
||||
Resume,
|
||||
Pause,
|
||||
Stop,
|
||||
Save,
|
||||
NextSong,
|
||||
SyncDatabase(Vec<Artist>, Vec<Album>, Vec<Song>),
|
||||
QueueUpdate(Vec<usize>, Queue),
|
||||
@@ -40,6 +39,7 @@ pub enum Command {
|
||||
QueueRemove(Vec<usize>),
|
||||
QueueGoto(Vec<usize>),
|
||||
QueueSetShuffle(Vec<usize>, Vec<usize>),
|
||||
|
||||
/// .id field is ignored!
|
||||
AddSong(Song),
|
||||
/// .id field is ignored!
|
||||
@@ -54,7 +54,26 @@ pub enum Command {
|
||||
RemoveArtist(ArtistId),
|
||||
ModifyArtist(Artist),
|
||||
SetSongDuration(SongId, u64),
|
||||
/// Add the given Tag to the song's tags, if it isn't set already.
|
||||
TagSongFlagSet(SongId, String),
|
||||
/// Remove the given Tag fron the song's tags, if it exists.
|
||||
TagSongFlagUnset(SongId, String),
|
||||
TagAlbumFlagSet(AlbumId, String),
|
||||
TagAlbumFlagUnset(AlbumId, String),
|
||||
TagArtistFlagSet(ArtistId, String),
|
||||
TagArtistFlagUnset(ArtistId, String),
|
||||
/// For the arguments `Key`, `Val`: If the song has a Tag `Key<anything>`, it will be removed. Then, `KeyVal` will be added.
|
||||
/// For example, to set "Year=2010", Key would be "Year=", and Val would be "2010". Then, "Year=1990", ..., would be removed and "Year=2010" would be added.
|
||||
TagSongPropertySet(SongId, String, String),
|
||||
/// For the arguments `Key`, `Val`: If the song has a Tag `Key<anything>`, it will be removed.
|
||||
TagSongPropertyUnset(SongId, String),
|
||||
TagAlbumPropertySet(AlbumId, String, String),
|
||||
TagAlbumPropertyUnset(AlbumId, String),
|
||||
TagArtistPropertySet(ArtistId, String, String),
|
||||
TagArtistPropertyUnset(ArtistId, String),
|
||||
|
||||
InitComplete,
|
||||
Save,
|
||||
ErrorInfo(String, String),
|
||||
}
|
||||
impl Command {
|
||||
@@ -195,102 +214,208 @@ pub fn handle_one_connection_as_control(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const BYTE_RESUME: u8 = 0b11000000;
|
||||
const BYTE_PAUSE: u8 = 0b00110000;
|
||||
const BYTE_STOP: u8 = 0b11110000;
|
||||
const BYTE_NEXT_SONG: u8 = 0b11110010;
|
||||
|
||||
const BYTE_SYNC_DATABASE: u8 = 0b01011000;
|
||||
const BYTE_QUEUE_UPDATE: u8 = 0b00011100;
|
||||
const BYTE_QUEUE_ADD: u8 = 0b00011010;
|
||||
const BYTE_QUEUE_INSERT: u8 = 0b00011110;
|
||||
const BYTE_QUEUE_REMOVE: u8 = 0b00011001;
|
||||
const BYTE_QUEUE_GOTO: u8 = 0b00011011;
|
||||
const BYTE_QUEUE_SET_SHUFFLE: u8 = 0b10011011;
|
||||
|
||||
const BYTE_ADD_SONG: u8 = 0b01010000;
|
||||
const BYTE_ADD_ALBUM: u8 = 0b01010011;
|
||||
const BYTE_ADD_ARTIST: u8 = 0b01011100;
|
||||
const BYTE_ADD_COVER: u8 = 0b01011101;
|
||||
const BYTE_MODIFY_SONG: u8 = 0b10010000;
|
||||
const BYTE_MODIFY_ALBUM: u8 = 0b10010011;
|
||||
const BYTE_MODIFY_ARTIST: u8 = 0b10011100;
|
||||
const BYTE_REMOVE_SONG: u8 = 0b11010000;
|
||||
const BYTE_REMOVE_ALBUM: u8 = 0b11010011;
|
||||
const BYTE_REMOVE_ARTIST: u8 = 0b11011100;
|
||||
const BYTE_TAG_SONG_FLAG_SET: u8 = 0b11100000;
|
||||
const BYTE_TAG_SONG_FLAG_UNSET: u8 = 0b11100001;
|
||||
const BYTE_TAG_ALBUM_FLAG_SET: u8 = 0b11100010;
|
||||
const BYTE_TAG_ALBUM_FLAG_UNSET: u8 = 0b11100011;
|
||||
const BYTE_TAG_ARTIST_FLAG_SET: u8 = 0b11100110;
|
||||
const BYTE_TAG_ARTIST_FLAG_UNSET: u8 = 0b11100111;
|
||||
const BYTE_TAG_SONG_PROPERTY_SET: u8 = 0b11101001;
|
||||
const BYTE_TAG_SONG_PROPERTY_UNSET: u8 = 0b11101010;
|
||||
const BYTE_TAG_ALBUM_PROPERTY_SET: u8 = 0b11101011;
|
||||
const BYTE_TAG_ALBUM_PROPERTY_UNSET: u8 = 0b11101100;
|
||||
const BYTE_TAG_ARTIST_PROPERTY_SET: u8 = 0b11101110;
|
||||
const BYTE_TAG_ARTIST_PROPERTY_UNSET: u8 = 0b11101111;
|
||||
|
||||
const BYTE_SET_SONG_DURATION: u8 = 0b11111000;
|
||||
|
||||
const BYTE_INIT_COMPLETE: u8 = 0b00110001;
|
||||
const BYTE_SAVE: u8 = 0b11110011;
|
||||
const BYTE_ERRORINFO: u8 = 0b11011011;
|
||||
|
||||
impl ToFromBytes for Command {
|
||||
fn to_bytes<T>(&self, s: &mut T) -> Result<(), std::io::Error>
|
||||
where
|
||||
T: Write,
|
||||
{
|
||||
match self {
|
||||
Self::Resume => s.write_all(&[0b11000000])?,
|
||||
Self::Pause => s.write_all(&[0b00110000])?,
|
||||
Self::Stop => s.write_all(&[0b11110000])?,
|
||||
Self::Save => s.write_all(&[0b11110011])?,
|
||||
Self::NextSong => s.write_all(&[0b11110010])?,
|
||||
Self::Resume => s.write_all(&[BYTE_RESUME])?,
|
||||
Self::Pause => s.write_all(&[BYTE_PAUSE])?,
|
||||
Self::Stop => s.write_all(&[BYTE_STOP])?,
|
||||
Self::NextSong => s.write_all(&[BYTE_NEXT_SONG])?,
|
||||
Self::SyncDatabase(a, b, c) => {
|
||||
s.write_all(&[0b01011000])?;
|
||||
s.write_all(&[BYTE_SYNC_DATABASE])?;
|
||||
a.to_bytes(s)?;
|
||||
b.to_bytes(s)?;
|
||||
c.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueUpdate(index, new_data) => {
|
||||
s.write_all(&[0b00011100])?;
|
||||
s.write_all(&[BYTE_QUEUE_UPDATE])?;
|
||||
index.to_bytes(s)?;
|
||||
new_data.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueAdd(index, new_data) => {
|
||||
s.write_all(&[0b00011010])?;
|
||||
s.write_all(&[BYTE_QUEUE_ADD])?;
|
||||
index.to_bytes(s)?;
|
||||
new_data.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueInsert(index, pos, new_data) => {
|
||||
s.write_all(&[0b00011110])?;
|
||||
s.write_all(&[BYTE_QUEUE_INSERT])?;
|
||||
index.to_bytes(s)?;
|
||||
pos.to_bytes(s)?;
|
||||
new_data.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueRemove(index) => {
|
||||
s.write_all(&[0b00011001])?;
|
||||
s.write_all(&[BYTE_QUEUE_REMOVE])?;
|
||||
index.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueGoto(index) => {
|
||||
s.write_all(&[0b00011011])?;
|
||||
s.write_all(&[BYTE_QUEUE_GOTO])?;
|
||||
index.to_bytes(s)?;
|
||||
}
|
||||
Self::QueueSetShuffle(path, map) => {
|
||||
s.write_all(&[0b10011011])?;
|
||||
s.write_all(&[BYTE_QUEUE_SET_SHUFFLE])?;
|
||||
path.to_bytes(s)?;
|
||||
map.to_bytes(s)?;
|
||||
}
|
||||
Self::AddSong(song) => {
|
||||
s.write_all(&[0b01010000])?;
|
||||
s.write_all(&[BYTE_ADD_SONG])?;
|
||||
song.to_bytes(s)?;
|
||||
}
|
||||
Self::AddAlbum(album) => {
|
||||
s.write_all(&[0b01010011])?;
|
||||
s.write_all(&[BYTE_ADD_ALBUM])?;
|
||||
album.to_bytes(s)?;
|
||||
}
|
||||
Self::AddArtist(artist) => {
|
||||
s.write_all(&[0b01011100])?;
|
||||
s.write_all(&[BYTE_ADD_ARTIST])?;
|
||||
artist.to_bytes(s)?;
|
||||
}
|
||||
Self::AddCover(cover) => {
|
||||
s.write_all(&[0b01011101])?;
|
||||
s.write_all(&[BYTE_ADD_COVER])?;
|
||||
cover.to_bytes(s)?;
|
||||
}
|
||||
Self::ModifySong(song) => {
|
||||
s.write_all(&[0b10010000])?;
|
||||
s.write_all(&[BYTE_MODIFY_SONG])?;
|
||||
song.to_bytes(s)?;
|
||||
}
|
||||
Self::ModifyAlbum(album) => {
|
||||
s.write_all(&[0b10010011])?;
|
||||
s.write_all(&[BYTE_MODIFY_ALBUM])?;
|
||||
album.to_bytes(s)?;
|
||||
}
|
||||
Self::ModifyArtist(artist) => {
|
||||
s.write_all(&[0b10011100])?;
|
||||
s.write_all(&[BYTE_MODIFY_ARTIST])?;
|
||||
artist.to_bytes(s)?;
|
||||
}
|
||||
Self::RemoveSong(song) => {
|
||||
s.write_all(&[0b11010000])?;
|
||||
s.write_all(&[BYTE_REMOVE_SONG])?;
|
||||
song.to_bytes(s)?;
|
||||
}
|
||||
Self::RemoveAlbum(album) => {
|
||||
s.write_all(&[0b11010011])?;
|
||||
s.write_all(&[BYTE_REMOVE_ALBUM])?;
|
||||
album.to_bytes(s)?;
|
||||
}
|
||||
Self::RemoveArtist(artist) => {
|
||||
s.write_all(&[0b11011100])?;
|
||||
s.write_all(&[BYTE_REMOVE_ARTIST])?;
|
||||
artist.to_bytes(s)?;
|
||||
}
|
||||
Self::TagSongFlagSet(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_SONG_FLAG_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagSongFlagUnset(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_SONG_FLAG_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagAlbumFlagSet(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_ALBUM_FLAG_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagAlbumFlagUnset(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_ALBUM_FLAG_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagArtistFlagSet(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_ARTIST_FLAG_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagArtistFlagUnset(id, tag) => {
|
||||
s.write_all(&[BYTE_TAG_ARTIST_FLAG_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
tag.to_bytes(s)?;
|
||||
}
|
||||
Self::TagSongPropertySet(id, key, val) => {
|
||||
s.write_all(&[BYTE_TAG_SONG_PROPERTY_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
val.to_bytes(s)?;
|
||||
}
|
||||
Self::TagSongPropertyUnset(id, key) => {
|
||||
s.write_all(&[BYTE_TAG_SONG_PROPERTY_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
}
|
||||
Self::TagAlbumPropertySet(id, key, val) => {
|
||||
s.write_all(&[BYTE_TAG_ALBUM_PROPERTY_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
val.to_bytes(s)?;
|
||||
}
|
||||
Self::TagAlbumPropertyUnset(id, key) => {
|
||||
s.write_all(&[BYTE_TAG_ALBUM_PROPERTY_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
}
|
||||
Self::TagArtistPropertySet(id, key, val) => {
|
||||
s.write_all(&[BYTE_TAG_ARTIST_PROPERTY_SET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
val.to_bytes(s)?;
|
||||
}
|
||||
Self::TagArtistPropertyUnset(id, key) => {
|
||||
s.write_all(&[BYTE_TAG_ARTIST_PROPERTY_UNSET])?;
|
||||
id.to_bytes(s)?;
|
||||
key.to_bytes(s)?;
|
||||
}
|
||||
Self::SetSongDuration(i, d) => {
|
||||
s.write_all(&[0b11100000])?;
|
||||
s.write_all(&[BYTE_SET_SONG_DURATION])?;
|
||||
i.to_bytes(s)?;
|
||||
d.to_bytes(s)?;
|
||||
}
|
||||
Self::InitComplete => {
|
||||
s.write_all(&[0b00110001])?;
|
||||
s.write_all(&[BYTE_INIT_COMPLETE])?;
|
||||
}
|
||||
Self::Save => s.write_all(&[BYTE_SAVE])?,
|
||||
Self::ErrorInfo(t, d) => {
|
||||
s.write_all(&[0b11011011])?;
|
||||
s.write_all(&[BYTE_ERRORINFO])?;
|
||||
t.to_bytes(s)?;
|
||||
d.to_bytes(s)?;
|
||||
}
|
||||
@@ -303,46 +428,61 @@ impl ToFromBytes for Command {
|
||||
{
|
||||
let mut kind = [0];
|
||||
s.read_exact(&mut kind)?;
|
||||
macro_rules! from_bytes {
|
||||
() => {
|
||||
ToFromBytes::from_bytes(s)?
|
||||
};
|
||||
}
|
||||
Ok(match kind[0] {
|
||||
0b11000000 => Self::Resume,
|
||||
0b00110000 => Self::Pause,
|
||||
0b11110000 => Self::Stop,
|
||||
0b11110011 => Self::Save,
|
||||
0b11110010 => Self::NextSong,
|
||||
0b01011000 => Self::SyncDatabase(
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
),
|
||||
0b00011100 => {
|
||||
Self::QueueUpdate(ToFromBytes::from_bytes(s)?, ToFromBytes::from_bytes(s)?)
|
||||
BYTE_RESUME => Self::Resume,
|
||||
BYTE_PAUSE => Self::Pause,
|
||||
BYTE_STOP => Self::Stop,
|
||||
BYTE_NEXT_SONG => Self::NextSong,
|
||||
BYTE_SYNC_DATABASE => Self::SyncDatabase(from_bytes!(), from_bytes!(), from_bytes!()),
|
||||
BYTE_QUEUE_UPDATE => Self::QueueUpdate(from_bytes!(), from_bytes!()),
|
||||
BYTE_QUEUE_ADD => Self::QueueAdd(from_bytes!(), from_bytes!()),
|
||||
BYTE_QUEUE_INSERT => Self::QueueInsert(from_bytes!(), from_bytes!(), from_bytes!()),
|
||||
BYTE_QUEUE_REMOVE => Self::QueueRemove(from_bytes!()),
|
||||
BYTE_QUEUE_GOTO => Self::QueueGoto(from_bytes!()),
|
||||
BYTE_QUEUE_SET_SHUFFLE => Self::QueueSetShuffle(from_bytes!(), from_bytes!()),
|
||||
BYTE_ADD_SONG => Self::AddSong(from_bytes!()),
|
||||
BYTE_ADD_ALBUM => Self::AddAlbum(from_bytes!()),
|
||||
BYTE_ADD_ARTIST => Self::AddArtist(from_bytes!()),
|
||||
BYTE_MODIFY_SONG => Self::ModifySong(from_bytes!()),
|
||||
BYTE_MODIFY_ALBUM => Self::ModifyAlbum(from_bytes!()),
|
||||
BYTE_MODIFY_ARTIST => Self::ModifyArtist(from_bytes!()),
|
||||
BYTE_REMOVE_SONG => Self::RemoveSong(from_bytes!()),
|
||||
BYTE_REMOVE_ALBUM => Self::RemoveAlbum(from_bytes!()),
|
||||
BYTE_REMOVE_ARTIST => Self::RemoveArtist(from_bytes!()),
|
||||
BYTE_TAG_SONG_FLAG_SET => Self::TagSongFlagSet(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_SONG_FLAG_UNSET => Self::TagSongFlagUnset(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_ALBUM_FLAG_SET => Self::TagAlbumFlagSet(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_ALBUM_FLAG_UNSET => Self::TagAlbumFlagUnset(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_ARTIST_FLAG_SET => Self::TagArtistFlagSet(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_ARTIST_FLAG_UNSET => Self::TagArtistFlagUnset(from_bytes!(), from_bytes!()),
|
||||
BYTE_TAG_SONG_PROPERTY_SET => {
|
||||
Self::TagSongPropertySet(from_bytes!(), from_bytes!(), from_bytes!())
|
||||
}
|
||||
0b00011010 => Self::QueueAdd(ToFromBytes::from_bytes(s)?, ToFromBytes::from_bytes(s)?),
|
||||
0b00011110 => Self::QueueInsert(
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
ToFromBytes::from_bytes(s)?,
|
||||
),
|
||||
0b00011001 => Self::QueueRemove(ToFromBytes::from_bytes(s)?),
|
||||
0b00011011 => Self::QueueGoto(ToFromBytes::from_bytes(s)?),
|
||||
0b10011011 => {
|
||||
Self::QueueSetShuffle(ToFromBytes::from_bytes(s)?, ToFromBytes::from_bytes(s)?)
|
||||
BYTE_TAG_SONG_PROPERTY_UNSET => {
|
||||
Self::TagSongPropertyUnset(from_bytes!(), from_bytes!())
|
||||
}
|
||||
0b01010000 => Self::AddSong(ToFromBytes::from_bytes(s)?),
|
||||
0b01010011 => Self::AddAlbum(ToFromBytes::from_bytes(s)?),
|
||||
0b01011100 => Self::AddArtist(ToFromBytes::from_bytes(s)?),
|
||||
0b10010000 => Self::ModifySong(ToFromBytes::from_bytes(s)?),
|
||||
0b10010011 => Self::ModifyAlbum(ToFromBytes::from_bytes(s)?),
|
||||
0b10011100 => Self::ModifyArtist(ToFromBytes::from_bytes(s)?),
|
||||
0b11010000 => Self::RemoveSong(ToFromBytes::from_bytes(s)?),
|
||||
0b11010011 => Self::RemoveAlbum(ToFromBytes::from_bytes(s)?),
|
||||
0b11011100 => Self::RemoveArtist(ToFromBytes::from_bytes(s)?),
|
||||
0b11100000 => {
|
||||
Self::SetSongDuration(ToFromBytes::from_bytes(s)?, ToFromBytes::from_bytes(s)?)
|
||||
BYTE_TAG_ALBUM_PROPERTY_SET => {
|
||||
Self::TagAlbumPropertySet(from_bytes!(), from_bytes!(), from_bytes!())
|
||||
}
|
||||
0b01011101 => Self::AddCover(ToFromBytes::from_bytes(s)?),
|
||||
0b00110001 => Self::InitComplete,
|
||||
0b11011011 => Self::ErrorInfo(ToFromBytes::from_bytes(s)?, ToFromBytes::from_bytes(s)?),
|
||||
BYTE_TAG_ALBUM_PROPERTY_UNSET => {
|
||||
Self::TagAlbumPropertyUnset(from_bytes!(), from_bytes!())
|
||||
}
|
||||
BYTE_TAG_ARTIST_PROPERTY_SET => {
|
||||
Self::TagArtistPropertySet(from_bytes!(), from_bytes!(), from_bytes!())
|
||||
}
|
||||
BYTE_TAG_ARTIST_PROPERTY_UNSET => {
|
||||
Self::TagArtistPropertyUnset(from_bytes!(), from_bytes!())
|
||||
}
|
||||
BYTE_SET_SONG_DURATION => Self::SetSongDuration(from_bytes!(), from_bytes!()),
|
||||
BYTE_ADD_COVER => Self::AddCover(from_bytes!()),
|
||||
BYTE_INIT_COMPLETE => Self::InitComplete,
|
||||
BYTE_SAVE => Self::Save,
|
||||
BYTE_ERRORINFO => Self::ErrorInfo(from_bytes!(), from_bytes!()),
|
||||
_ => {
|
||||
eprintln!("unexpected byte when reading command; stopping playback.");
|
||||
Self::Stop
|
||||
|
||||
Reference in New Issue
Block a user