package com.mulberry.player; import android.content.ContentUris; import android.net.Uri; import android.provider.MediaStore; import org.jaudiotagger.tag.id3.framebody.FrameBodyCOMM; import org.json.JSONException; import org.json.JSONObject; /* JADX INFO: loaded from: classes.dex */ public final class Song { public long dateAdded; public long duration; public int track; public int year; public long id = -1; public String uri = FrameBodyCOMM.DEFAULT; public String path = FrameBodyCOMM.DEFAULT; public String title = FrameBodyCOMM.DEFAULT; public String artist = FrameBodyCOMM.DEFAULT; public String album = FrameBodyCOMM.DEFAULT; public String albumArtist = FrameBodyCOMM.DEFAULT; public long albumId = -1; public String mime = FrameBodyCOMM.DEFAULT; public String folder = FrameBodyCOMM.DEFAULT; public static Song fromStore(long j) { Song song = new Song(); song.id = j; song.uri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, j).toString(); return song; } public Uri toUri() { return Uri.parse(this.uri); } public boolean isStream() { return this.uri.startsWith("http://") || this.uri.startsWith("https://"); } public String displayTitle() { if (this.title != null && this.title.length() > 0) { return this.title; } if (this.path != null && this.path.length() > 0) { String strSubstring = this.path.substring(this.path.lastIndexOf(47) + 1); int iLastIndexOf = strSubstring.lastIndexOf(46); return iLastIndexOf > 0 ? strSubstring.substring(0, iLastIndexOf) : strSubstring; } return this.uri; } public String displayArtist() { if (this.artist == null || this.artist.length() <= 0 || "".equals(this.artist)) { return this.albumArtist != null ? this.albumArtist : FrameBodyCOMM.DEFAULT; } return this.artist; } public String key() { return this.id >= 0 ? "id:" + this.id : this.uri; } public JSONObject toJson() { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("id", this.id); jSONObject.put("uri", this.uri); jSONObject.put("path", this.path); jSONObject.put("title", this.title); jSONObject.put("artist", this.artist); jSONObject.put("album", this.album); jSONObject.put("aa", this.albumArtist); jSONObject.put("aid", this.albumId); jSONObject.put("dur", this.duration); jSONObject.put("tr", this.track); jSONObject.put("yr", this.year); } catch (JSONException e) { } return jSONObject; } public static Song fromJson(JSONObject jSONObject) { Song song = new Song(); song.id = jSONObject.optLong("id", -1L); song.uri = jSONObject.optString("uri"); song.path = jSONObject.optString("path"); song.title = jSONObject.optString("title"); song.artist = jSONObject.optString("artist"); song.album = jSONObject.optString("album"); song.albumArtist = jSONObject.optString("aa"); song.albumId = jSONObject.optLong("aid", -1L); song.duration = jSONObject.optLong("dur"); song.track = jSONObject.optInt("tr"); song.year = jSONObject.optInt("yr"); return song; } }