2020-11-20 15:38:08 +01:00
|
|
|
package com.cappielloantonio.play.model;
|
|
|
|
|
|
|
|
|
|
import android.os.Parcel;
|
|
|
|
|
import android.os.Parcelable;
|
|
|
|
|
|
2021-09-04 16:14:10 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2021-07-26 19:03:51 +02:00
|
|
|
import com.cappielloantonio.play.subsonic.models.Child;
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
import java.util.Date;
|
2020-11-20 15:38:08 +01:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public class Media implements Parcelable {
|
|
|
|
|
private static final String TAG = "Media";
|
2021-04-14 14:06:35 +02:00
|
|
|
|
2022-02-07 09:48:15 +01:00
|
|
|
public static String MEDIA_TYPE_MUSIC = "music";
|
|
|
|
|
public static String MEDIA_TYPE_PODCAST = "podcast";
|
|
|
|
|
public static String MEDIA_TYPE_AUDIOBOOK = "audiobook";
|
|
|
|
|
public static String MEDIA_TYPE_VIDEO = "video";
|
|
|
|
|
|
2020-11-24 10:52:00 +01:00
|
|
|
public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED";
|
|
|
|
|
public static final String MOST_PLAYED = "MOST_PLAYED";
|
|
|
|
|
public static final String RECENTLY_ADDED = "RECENTLY_ADDED";
|
|
|
|
|
public static final String BY_GENRE = "BY_GENRE";
|
2020-11-25 08:21:30 +01:00
|
|
|
public static final String BY_GENRES = "BY_GENRES";
|
2020-11-24 10:52:00 +01:00
|
|
|
public static final String BY_ARTIST = "BY_ARTIST";
|
2020-11-28 14:50:15 +01:00
|
|
|
public static final String BY_YEAR = "BY_YEAR";
|
2021-07-30 17:12:08 +02:00
|
|
|
public static final String STARRED = "STARRED";
|
2021-04-26 19:37:05 +02:00
|
|
|
public static final String DOWNLOADED = "DOWNLOADED";
|
2021-08-30 12:38:43 +02:00
|
|
|
public static final String FROM_ALBUM = "FROM_ALBUM";
|
2021-04-18 20:23:09 +02:00
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
private String id;
|
|
|
|
|
private String title;
|
|
|
|
|
private int trackNumber;
|
|
|
|
|
private int discNumber;
|
|
|
|
|
private int year;
|
|
|
|
|
private long duration;
|
|
|
|
|
private String albumId;
|
|
|
|
|
private String albumName;
|
|
|
|
|
private String artistId;
|
|
|
|
|
private String artistName;
|
|
|
|
|
private String primary;
|
2021-07-27 12:10:28 +02:00
|
|
|
private String blurHash;
|
2020-11-20 15:38:08 +01:00
|
|
|
private boolean favorite;
|
|
|
|
|
private String path;
|
|
|
|
|
private long size;
|
|
|
|
|
private String container;
|
|
|
|
|
private int bitRate;
|
2020-11-22 19:11:38 +01:00
|
|
|
private long added;
|
2022-02-07 09:47:46 +01:00
|
|
|
private String type;
|
2020-11-22 19:11:38 +01:00
|
|
|
private int playCount;
|
|
|
|
|
private long lastPlay;
|
2021-08-13 17:29:37 +02:00
|
|
|
private int rating;
|
2021-04-26 19:17:42 +02:00
|
|
|
|
2022-02-07 09:49:06 +01:00
|
|
|
private String streamId;
|
|
|
|
|
private String channelId;
|
|
|
|
|
private String description;
|
|
|
|
|
private String status;
|
|
|
|
|
private Date publishDate;
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public Media() {
|
2020-12-09 19:31:35 +01:00
|
|
|
this.id = UUID.randomUUID().toString();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public Media(Child child) {
|
2021-07-26 19:03:51 +02:00
|
|
|
this.id = child.getId();
|
|
|
|
|
this.title = child.getTitle();
|
2021-08-19 13:02:23 +02:00
|
|
|
this.trackNumber = child.getTrack() != null ? child.getTrack() : 0;
|
2021-08-05 10:05:21 +02:00
|
|
|
this.discNumber = child.getDiscNumber() != null ? child.getDiscNumber() : 0;
|
2021-07-27 12:10:28 +02:00
|
|
|
this.year = child.getYear() != null ? child.getYear() : 0;
|
2021-07-26 19:03:51 +02:00
|
|
|
this.duration = child.getDuration();
|
|
|
|
|
this.albumId = child.getAlbumId();
|
|
|
|
|
this.albumName = child.getAlbum();
|
|
|
|
|
this.artistId = child.getArtistId();
|
|
|
|
|
this.artistName = child.getArtist();
|
|
|
|
|
this.primary = child.getCoverArtId();
|
|
|
|
|
this.favorite = child.getStarred() != null;
|
|
|
|
|
this.path = child.getPath();
|
|
|
|
|
this.size = child.getSize();
|
|
|
|
|
this.container = child.getContentType();
|
|
|
|
|
this.bitRate = child.getBitRate();
|
|
|
|
|
this.added = child.getCreated().getTime();
|
2020-11-22 19:11:38 +01:00
|
|
|
this.playCount = 0;
|
|
|
|
|
this.lastPlay = 0;
|
2021-08-13 17:29:37 +02:00
|
|
|
this.rating = child.getUserRating() != null ? child.getUserRating() : 0;
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public Media(Queue queue) {
|
2021-07-28 15:28:32 +02:00
|
|
|
this.id = queue.getSongID();
|
|
|
|
|
this.title = queue.getTitle();
|
|
|
|
|
this.albumId = queue.getAlbumId();
|
|
|
|
|
this.albumName = queue.getAlbumName();
|
|
|
|
|
this.artistId = queue.getArtistId();
|
|
|
|
|
this.artistName = queue.getArtistName();
|
|
|
|
|
this.primary = queue.getPrimary();
|
2021-07-28 18:53:42 +02:00
|
|
|
this.duration = queue.getDuration();
|
2021-07-28 15:28:32 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public Media(Download download) {
|
2021-07-29 17:12:55 +02:00
|
|
|
this.id = download.getSongID();
|
|
|
|
|
this.title = download.getTitle();
|
|
|
|
|
this.albumId = download.getAlbumId();
|
|
|
|
|
this.albumName = download.getAlbumName();
|
|
|
|
|
this.artistId = download.getArtistId();
|
|
|
|
|
this.artistName = download.getArtistName();
|
2021-09-02 14:18:10 +02:00
|
|
|
this.trackNumber = download.getTrackNumber();
|
2021-07-29 17:12:55 +02:00
|
|
|
this.primary = download.getPrimary();
|
|
|
|
|
this.duration = download.getDuration();
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
public String getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTrackNumber() {
|
|
|
|
|
return trackNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDiscNumber() {
|
|
|
|
|
return discNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getYear() {
|
|
|
|
|
return year;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getDuration() {
|
|
|
|
|
return duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAlbumId() {
|
|
|
|
|
return albumId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAlbumName() {
|
|
|
|
|
return albumName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getArtistId() {
|
|
|
|
|
return artistId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getArtistName() {
|
|
|
|
|
return artistName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPrimary() {
|
|
|
|
|
return primary;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-27 12:10:28 +02:00
|
|
|
public String getBlurHash() {
|
|
|
|
|
return blurHash;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
public boolean isFavorite() {
|
|
|
|
|
return favorite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPath() {
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getSize() {
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getContainer() {
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getBitRate() {
|
|
|
|
|
return bitRate;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 19:11:38 +01:00
|
|
|
public long getAdded() {
|
|
|
|
|
return added;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getPlayCount() {
|
|
|
|
|
return playCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getLastPlay() {
|
|
|
|
|
return lastPlay;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 15:28:32 +02:00
|
|
|
public void setId(String id) {
|
2020-11-20 15:38:08 +01:00
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
|
this.title = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTrackNumber(int trackNumber) {
|
|
|
|
|
this.trackNumber = trackNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDiscNumber(int discNumber) {
|
|
|
|
|
this.discNumber = discNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setYear(int year) {
|
|
|
|
|
this.year = year;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDuration(long duration) {
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAlbumId(String albumId) {
|
|
|
|
|
this.albumId = albumId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAlbumName(String albumName) {
|
|
|
|
|
this.albumName = albumName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setArtistId(String artistId) {
|
|
|
|
|
this.artistId = artistId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setArtistName(String artistName) {
|
|
|
|
|
this.artistName = artistName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPrimary(String primary) {
|
|
|
|
|
this.primary = primary;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-27 12:10:28 +02:00
|
|
|
public void setBlurHash(String blurHash) {
|
|
|
|
|
this.blurHash = blurHash;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
public void setFavorite(boolean favorite) {
|
|
|
|
|
this.favorite = favorite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPath(String path) {
|
|
|
|
|
this.path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSize(long size) {
|
|
|
|
|
this.size = size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setContainer(String container) {
|
|
|
|
|
this.container = container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBitRate(int bitRate) {
|
|
|
|
|
this.bitRate = bitRate;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 19:11:38 +01:00
|
|
|
public void setAdded(long added) {
|
|
|
|
|
this.added = added;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLastPlay(long lastPlay) {
|
|
|
|
|
this.lastPlay = lastPlay;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-27 09:06:50 +01:00
|
|
|
public void setPlayCount(int playCount) {
|
|
|
|
|
this.playCount = playCount;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-13 17:29:37 +02:00
|
|
|
public int getRating() {
|
|
|
|
|
return rating;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRating(int rating) {
|
|
|
|
|
this.rating = rating;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-20 15:38:08 +01:00
|
|
|
@Override
|
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
|
if (this == o) return true;
|
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
Media song = (Media) o;
|
2020-11-20 15:38:08 +01:00
|
|
|
return id.equals(song.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int hashCode() {
|
|
|
|
|
return id.hashCode();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-04 16:14:10 +02:00
|
|
|
@NonNull
|
2020-11-20 15:38:08 +01:00
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int describeContents() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void writeToParcel(Parcel dest, int flags) {
|
|
|
|
|
dest.writeString(this.id);
|
|
|
|
|
dest.writeString(this.title);
|
|
|
|
|
dest.writeInt(this.trackNumber);
|
|
|
|
|
dest.writeInt(this.discNumber);
|
|
|
|
|
dest.writeInt(this.year);
|
|
|
|
|
dest.writeLong(this.duration);
|
|
|
|
|
dest.writeString(this.albumId);
|
|
|
|
|
dest.writeString(this.albumName);
|
|
|
|
|
dest.writeString(this.artistId);
|
|
|
|
|
dest.writeString(this.artistName);
|
|
|
|
|
dest.writeString(this.primary);
|
|
|
|
|
dest.writeString(Boolean.toString(favorite));
|
2021-07-27 12:10:28 +02:00
|
|
|
dest.writeString(this.blurHash);
|
2020-11-20 15:38:08 +01:00
|
|
|
dest.writeString(this.path);
|
|
|
|
|
dest.writeLong(this.size);
|
|
|
|
|
dest.writeString(this.container);
|
|
|
|
|
dest.writeInt(this.bitRate);
|
2020-11-22 19:11:38 +01:00
|
|
|
dest.writeLong(this.added);
|
|
|
|
|
dest.writeInt(this.playCount);
|
|
|
|
|
dest.writeLong(this.lastPlay);
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
protected Media(Parcel in) {
|
2020-11-20 15:38:08 +01:00
|
|
|
this.id = in.readString();
|
|
|
|
|
this.title = in.readString();
|
|
|
|
|
this.trackNumber = in.readInt();
|
|
|
|
|
this.discNumber = in.readInt();
|
|
|
|
|
this.year = in.readInt();
|
|
|
|
|
this.duration = in.readLong();
|
|
|
|
|
this.albumId = in.readString();
|
|
|
|
|
this.albumName = in.readString();
|
|
|
|
|
this.artistId = in.readString();
|
|
|
|
|
this.artistName = in.readString();
|
|
|
|
|
this.primary = in.readString();
|
|
|
|
|
this.favorite = Boolean.parseBoolean(in.readString());
|
2021-07-27 12:10:28 +02:00
|
|
|
this.blurHash = in.readString();
|
2020-11-20 15:38:08 +01:00
|
|
|
this.path = in.readString();
|
|
|
|
|
this.size = in.readLong();
|
|
|
|
|
this.container = in.readString();
|
|
|
|
|
this.bitRate = in.readInt();
|
2020-11-22 19:11:38 +01:00
|
|
|
this.added = in.readLong();
|
|
|
|
|
this.playCount = in.readInt();
|
|
|
|
|
this.lastPlay = in.readLong();
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public static final Creator<Media> CREATOR = new Creator<Media>() {
|
|
|
|
|
public Media createFromParcel(Parcel source) {
|
|
|
|
|
return new Media(source);
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-07 09:47:46 +01:00
|
|
|
public Media[] newArray(int size) {
|
|
|
|
|
return new Media[size];
|
2020-11-20 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|