mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-28 14:42:16 +03:00
Unify terminology also by renaming DownloadFile.song -> DownloadFile.track
This commit is contained in:
parent
2de59b2206
commit
e53da92dac
@ -1,5 +1,7 @@
|
|||||||
package org.moire.ultrasonic.receiver;
|
package org.moire.ultrasonic.receiver;
|
||||||
|
|
||||||
|
import static org.koin.java.KoinJavaComponent.inject;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -9,8 +11,6 @@ import org.moire.ultrasonic.service.MediaPlayerController;
|
|||||||
|
|
||||||
import kotlin.Lazy;
|
import kotlin.Lazy;
|
||||||
|
|
||||||
import static org.koin.java.KoinJavaComponent.inject;
|
|
||||||
|
|
||||||
public class A2dpIntentReceiver extends BroadcastReceiver
|
public class A2dpIntentReceiver extends BroadcastReceiver
|
||||||
{
|
{
|
||||||
private static final String PLAYSTATUS_RESPONSE = "com.android.music.playstatusresponse";
|
private static final String PLAYSTATUS_RESPONSE = "com.android.music.playstatusresponse";
|
||||||
@ -21,7 +21,7 @@ public class A2dpIntentReceiver extends BroadcastReceiver
|
|||||||
{
|
{
|
||||||
if (mediaPlayerControllerLazy.getValue().getCurrentPlaying() == null) return;
|
if (mediaPlayerControllerLazy.getValue().getCurrentPlaying() == null) return;
|
||||||
|
|
||||||
Track song = mediaPlayerControllerLazy.getValue().getCurrentPlaying().getSong();
|
Track song = mediaPlayerControllerLazy.getValue().getCurrentPlaying().getTrack();
|
||||||
if (song == null) return;
|
if (song == null) return;
|
||||||
|
|
||||||
Intent avrcpIntent = new Intent(PLAYSTATUS_RESPONSE);
|
Intent avrcpIntent = new Intent(PLAYSTATUS_RESPONSE);
|
||||||
|
@ -234,7 +234,7 @@ public class JukeboxMediaPlayer
|
|||||||
List<String> ids = new ArrayList<>();
|
List<String> ids = new ArrayList<>();
|
||||||
for (DownloadFile file : downloader.getAll())
|
for (DownloadFile file : downloader.getAll())
|
||||||
{
|
{
|
||||||
ids.add(file.getSong().getId());
|
ids.add(file.getTrack().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.add(new SetPlaylist(ids));
|
tasks.add(new SetPlaylist(ids));
|
||||||
|
@ -18,7 +18,7 @@ public class Scrobbler
|
|||||||
{
|
{
|
||||||
if (song == null || !ActiveServerProvider.Companion.isScrobblingEnabled()) return;
|
if (song == null || !ActiveServerProvider.Companion.isScrobblingEnabled()) return;
|
||||||
|
|
||||||
final String id = song.getSong().getId();
|
final String id = song.getTrack().getId();
|
||||||
if (id == null) return;
|
if (id == null) return;
|
||||||
|
|
||||||
// Avoid duplicate registrations.
|
// Avoid duplicate registrations.
|
||||||
|
@ -180,7 +180,7 @@ public class StreamProxy implements Runnable
|
|||||||
{
|
{
|
||||||
Timber.i("Streaming song in background");
|
Timber.i("Streaming song in background");
|
||||||
DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get();
|
DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get();
|
||||||
MusicDirectory.Track song = downloadFile.getSong();
|
MusicDirectory.Track song = downloadFile.getTrack();
|
||||||
long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
|
long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
|
||||||
Timber.i("Streaming fileSize: %d", fileSize);
|
Timber.i("Streaming fileSize: %d", fileSize);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class TrackViewBinder(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Minimize or maximize the Text view (if song title is very long)
|
// Minimize or maximize the Text view (if song title is very long)
|
||||||
if (!downloadFile.song.isDirectory) {
|
if (!downloadFile.track.isDirectory) {
|
||||||
holder.maximizeOrMinimize()
|
holder.maximizeOrMinimize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ class TrackViewBinder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
if (checkable && !downloadFile.song.isVideo) {
|
if (checkable && !downloadFile.track.isVideo) {
|
||||||
val nowChecked = !holder.check.isChecked
|
val nowChecked = !holder.check.isChecked
|
||||||
holder.isChecked = nowChecked
|
holder.isChecked = nowChecked
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,7 +67,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable
|
|||||||
isSelected: Boolean = false
|
isSelected: Boolean = false
|
||||||
) {
|
) {
|
||||||
val useFiveStarRating = Settings.useFiveStarRating
|
val useFiveStarRating = Settings.useFiveStarRating
|
||||||
val song = file.song
|
val song = file.track
|
||||||
downloadFile = file
|
downloadFile = file
|
||||||
entry = song
|
entry = song
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class NowPlayingFragment : Fragment() {
|
|||||||
val file = mediaPlayerController.currentPlaying
|
val file = mediaPlayerController.currentPlaying
|
||||||
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
val song = file.song
|
val song = file.track
|
||||||
val title = song.title
|
val title = song.title
|
||||||
val artist = song.artist
|
val artist = song.artist
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ class PlayerFragment :
|
|||||||
val downloadFile = mediaPlayerController.currentPlaying
|
val downloadFile = mediaPlayerController.currentPlaying
|
||||||
|
|
||||||
if (downloadFile != null) {
|
if (downloadFile != null) {
|
||||||
currentSong = downloadFile.song
|
currentSong = downloadFile.track
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useFiveStarRating) starMenuItem.isVisible = false
|
if (useFiveStarRating) starMenuItem.isVisible = false
|
||||||
@ -546,7 +546,7 @@ class PlayerFragment :
|
|||||||
menuInflater.inflate(R.menu.nowplaying_context, menu)
|
menuInflater.inflate(R.menu.nowplaying_context, menu)
|
||||||
val song: MusicDirectory.Track?
|
val song: MusicDirectory.Track?
|
||||||
|
|
||||||
song = downloadFile.song
|
song = downloadFile.track
|
||||||
|
|
||||||
if (song.parent == null) {
|
if (song.parent == null) {
|
||||||
val menuItem = menu.findItem(R.id.menu_show_album)
|
val menuItem = menu.findItem(R.id.menu_show_album)
|
||||||
@ -574,7 +574,7 @@ class PlayerFragment :
|
|||||||
var track: MusicDirectory.Track? = null
|
var track: MusicDirectory.Track? = null
|
||||||
val bundle: Bundle
|
val bundle: Bundle
|
||||||
if (song != null) {
|
if (song != null) {
|
||||||
track = song.song
|
track = song.track
|
||||||
}
|
}
|
||||||
|
|
||||||
when (menuItemId) {
|
when (menuItemId) {
|
||||||
@ -749,7 +749,7 @@ class PlayerFragment :
|
|||||||
val tracks: MutableList<MusicDirectory.Track?> = ArrayList()
|
val tracks: MutableList<MusicDirectory.Track?> = ArrayList()
|
||||||
val downloadServiceSongs = mediaPlayerController.playList
|
val downloadServiceSongs = mediaPlayerController.playList
|
||||||
for (downloadFile in downloadServiceSongs) {
|
for (downloadFile in downloadServiceSongs) {
|
||||||
val playlistEntry = downloadFile.song
|
val playlistEntry = downloadFile.track
|
||||||
tracks.add(playlistEntry)
|
tracks.add(playlistEntry)
|
||||||
}
|
}
|
||||||
shareHandler.createShare(this, tracks, null, cancellationToken)
|
shareHandler.createShare(this, tracks, null, cancellationToken)
|
||||||
@ -785,7 +785,7 @@ class PlayerFragment :
|
|||||||
ioScope.launch {
|
ioScope.launch {
|
||||||
|
|
||||||
val entries = mediaPlayerController.playList.map {
|
val entries = mediaPlayerController.playList.map {
|
||||||
it.song
|
it.track
|
||||||
}
|
}
|
||||||
val musicService = getMusicService()
|
val musicService = getMusicService()
|
||||||
musicService.createPlaylist(null, playlistName, entries)
|
musicService.createPlaylist(null, playlistName, entries)
|
||||||
@ -903,7 +903,7 @@ class PlayerFragment :
|
|||||||
|
|
||||||
val songRemoved = String.format(
|
val songRemoved = String.format(
|
||||||
resources.getString(R.string.download_song_removed),
|
resources.getString(R.string.download_song_removed),
|
||||||
file.song.title
|
file.track.title
|
||||||
)
|
)
|
||||||
Util.toast(context, songRemoved)
|
Util.toast(context, songRemoved)
|
||||||
|
|
||||||
@ -980,7 +980,7 @@ class PlayerFragment :
|
|||||||
val trackFormat =
|
val trackFormat =
|
||||||
String.format(Locale.getDefault(), "%d / %d", currentSongIndex, totalSongs)
|
String.format(Locale.getDefault(), "%d / %d", currentSongIndex, totalSongs)
|
||||||
if (currentPlaying != null) {
|
if (currentPlaying != null) {
|
||||||
currentSong = currentPlaying!!.song
|
currentSong = currentPlaying!!.track
|
||||||
songTitleTextView.text = currentSong!!.title
|
songTitleTextView.text = currentSong!!.title
|
||||||
artistTextView.text = currentSong!!.artist
|
artistTextView.text = currentSong!!.artist
|
||||||
albumTextView.text = currentSong!!.album
|
albumTextView.text = currentSong!!.album
|
||||||
|
@ -360,7 +360,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
|
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.song_menu_play_now -> {
|
R.id.song_menu_play_now -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
downloadHandler.download(
|
downloadHandler.download(
|
||||||
fragment = this,
|
fragment = this,
|
||||||
append = false,
|
append = false,
|
||||||
@ -372,7 +372,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
R.id.song_menu_play_next -> {
|
R.id.song_menu_play_next -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
downloadHandler.download(
|
downloadHandler.download(
|
||||||
fragment = this,
|
fragment = this,
|
||||||
append = true,
|
append = true,
|
||||||
@ -384,7 +384,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
R.id.song_menu_play_last -> {
|
R.id.song_menu_play_last -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
downloadHandler.download(
|
downloadHandler.download(
|
||||||
fragment = this,
|
fragment = this,
|
||||||
append = true,
|
append = true,
|
||||||
@ -396,7 +396,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
R.id.song_menu_pin -> {
|
R.id.song_menu_pin -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
toast(
|
toast(
|
||||||
context,
|
context,
|
||||||
resources.getQuantityString(
|
resources.getQuantityString(
|
||||||
@ -408,7 +408,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
downloadBackground(true, songs)
|
downloadBackground(true, songs)
|
||||||
}
|
}
|
||||||
R.id.song_menu_download -> {
|
R.id.song_menu_download -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
toast(
|
toast(
|
||||||
context,
|
context,
|
||||||
resources.getQuantityString(
|
resources.getQuantityString(
|
||||||
@ -420,7 +420,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
downloadBackground(false, songs)
|
downloadBackground(false, songs)
|
||||||
}
|
}
|
||||||
R.id.song_menu_unpin -> {
|
R.id.song_menu_unpin -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
toast(
|
toast(
|
||||||
context,
|
context,
|
||||||
resources.getQuantityString(
|
resources.getQuantityString(
|
||||||
@ -432,7 +432,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||||||
mediaPlayerController.unpin(songs)
|
mediaPlayerController.unpin(songs)
|
||||||
}
|
}
|
||||||
R.id.song_menu_share -> {
|
R.id.song_menu_share -> {
|
||||||
songs.add(item.song)
|
songs.add(item.track)
|
||||||
shareHandler.createShare(this, songs, searchRefresh, cancellationToken!!)
|
shareHandler.createShare(this, songs, searchRefresh, cancellationToken!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||||||
|
|
||||||
viewAdapter.register(
|
viewAdapter.register(
|
||||||
TrackViewBinder(
|
TrackViewBinder(
|
||||||
onItemClick = { onItemClick(it.song) },
|
onItemClick = { onItemClick(it.track) },
|
||||||
onContextMenuClick = { menu, id -> onContextMenuItemSelected(menu, id.song) },
|
onContextMenuClick = { menu, id -> onContextMenuItemSelected(menu, id.track) },
|
||||||
checkable = true,
|
checkable = true,
|
||||||
draggable = false,
|
draggable = false,
|
||||||
context = requireContext(),
|
context = requireContext(),
|
||||||
|
@ -38,12 +38,12 @@ import timber.log.Timber
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DownloadFile(
|
class DownloadFile(
|
||||||
val song: MusicDirectory.Track,
|
val track: MusicDirectory.Track,
|
||||||
save: Boolean
|
save: Boolean
|
||||||
) : KoinComponent, Identifiable {
|
) : KoinComponent, Identifiable {
|
||||||
val partialFile: String
|
val partialFile: String
|
||||||
lateinit var completeFile: String
|
lateinit var completeFile: String
|
||||||
val saveFile: String = FileUtil.getSongFile(song)
|
val saveFile: String = FileUtil.getSongFile(track)
|
||||||
var shouldSave = save
|
var shouldSave = save
|
||||||
private var downloadTask: CancellableTask? = null
|
private var downloadTask: CancellableTask? = null
|
||||||
var isFailed = false
|
var isFailed = false
|
||||||
@ -104,7 +104,7 @@ class DownloadFile(
|
|||||||
* Returns the effective bit rate.
|
* Returns the effective bit rate.
|
||||||
*/
|
*/
|
||||||
fun getBitRate(): Int {
|
fun getBitRate(): Int {
|
||||||
return if (song.bitRate == null) desiredBitRate else song.bitRate!!
|
return if (track.bitRate == null) desiredBitRate else track.bitRate!!
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@ -221,7 +221,7 @@ class DownloadFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return String.format("DownloadFile (%s)", song)
|
return String.format("DownloadFile (%s)", track)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class DownloadTask : CancellableTask() {
|
private inner class DownloadTask : CancellableTask() {
|
||||||
@ -259,7 +259,7 @@ class DownloadFile(
|
|||||||
|
|
||||||
// Some devices seem to throw error on partial file which doesn't exist
|
// Some devices seem to throw error on partial file which doesn't exist
|
||||||
val needsDownloading: Boolean
|
val needsDownloading: Boolean
|
||||||
val duration = song.duration
|
val duration = track.duration
|
||||||
val fileLength = Storage.getFromPath(partialFile)?.length ?: 0
|
val fileLength = Storage.getFromPath(partialFile)?.length ?: 0
|
||||||
|
|
||||||
needsDownloading = (
|
needsDownloading = (
|
||||||
@ -269,7 +269,7 @@ class DownloadFile(
|
|||||||
if (needsDownloading) {
|
if (needsDownloading) {
|
||||||
// Attempt partial HTTP GET, appending to the file if it exists.
|
// Attempt partial HTTP GET, appending to the file if it exists.
|
||||||
val (inStream, isPartial) = musicService.getDownloadInputStream(
|
val (inStream, isPartial) = musicService.getDownloadInputStream(
|
||||||
song, fileLength, desiredBitRate, shouldSave
|
track, fileLength, desiredBitRate, shouldSave
|
||||||
)
|
)
|
||||||
|
|
||||||
inputStream = inStream
|
inputStream = inStream
|
||||||
@ -293,11 +293,11 @@ class DownloadFile(
|
|||||||
|
|
||||||
if (isCancelled) {
|
if (isCancelled) {
|
||||||
status.postValue(DownloadStatus.CANCELLED)
|
status.postValue(DownloadStatus.CANCELLED)
|
||||||
throw Exception(String.format("Download of '%s' was cancelled", song))
|
throw Exception(String.format("Download of '%s' was cancelled", track))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (song.artistId != null) {
|
if (track.artistId != null) {
|
||||||
cacheMetadata(song.artistId!!)
|
cacheMetadata(track.artistId!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadAndSaveCoverArt()
|
downloadAndSaveCoverArt()
|
||||||
@ -328,7 +328,7 @@ class DownloadFile(
|
|||||||
status.postValue(DownloadStatus.FAILED)
|
status.postValue(DownloadStatus.FAILED)
|
||||||
--retryCount
|
--retryCount
|
||||||
}
|
}
|
||||||
Timber.w(all, "Failed to download '%s'.", song)
|
Timber.w(all, "Failed to download '%s'.", track)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
inputStream.safeClose()
|
inputStream.safeClose()
|
||||||
@ -339,7 +339,7 @@ class DownloadFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return String.format("DownloadTask (%s)", song)
|
return String.format("DownloadTask (%s)", track)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cacheMetadata(artistId: String) {
|
private fun cacheMetadata(artistId: String) {
|
||||||
@ -367,9 +367,9 @@ class DownloadFile(
|
|||||||
|
|
||||||
private fun downloadAndSaveCoverArt() {
|
private fun downloadAndSaveCoverArt() {
|
||||||
try {
|
try {
|
||||||
if (!TextUtils.isEmpty(song.coverArt)) {
|
if (!TextUtils.isEmpty(track.coverArt)) {
|
||||||
// Download the largest size that we can display in the UI
|
// Download the largest size that we can display in the UI
|
||||||
imageLoaderProvider.getImageLoader().cacheCoverArt(song)
|
imageLoaderProvider.getImageLoader().cacheCoverArt(track)
|
||||||
}
|
}
|
||||||
} catch (all: Exception) {
|
} catch (all: Exception) {
|
||||||
Timber.e(all, "Failed to get cover art.")
|
Timber.e(all, "Failed to get cover art.")
|
||||||
@ -392,8 +392,8 @@ class DownloadFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setProgress(totalBytesCopied: Long) {
|
private fun setProgress(totalBytesCopied: Long) {
|
||||||
if (song.size != null) {
|
if (track.size != null) {
|
||||||
progress.postValue((totalBytesCopied * 100 / song.size!!).toInt())
|
progress.postValue((totalBytesCopied * 100 / track.size!!).toInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ class DownloadFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val id: String
|
override val id: String
|
||||||
get() = song.id
|
get() = track.id
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MAX_RETRIES = 5
|
const val MAX_RETRIES = 5
|
||||||
|
@ -234,7 +234,7 @@ class Downloader(
|
|||||||
get() {
|
get() {
|
||||||
var totalDuration: Long = 0
|
var totalDuration: Long = 0
|
||||||
for (downloadFile in playlist) {
|
for (downloadFile in playlist) {
|
||||||
val song = downloadFile.song
|
val song = downloadFile.track
|
||||||
if (!song.isDirectory) {
|
if (!song.isDirectory) {
|
||||||
if (song.artist != null) {
|
if (song.artist != null) {
|
||||||
if (song.duration != null) {
|
if (song.duration != null) {
|
||||||
@ -437,17 +437,17 @@ class Downloader(
|
|||||||
@Suppress("ReturnCount")
|
@Suppress("ReturnCount")
|
||||||
fun getDownloadFileForSong(song: MusicDirectory.Track): DownloadFile {
|
fun getDownloadFileForSong(song: MusicDirectory.Track): DownloadFile {
|
||||||
for (downloadFile in playlist) {
|
for (downloadFile in playlist) {
|
||||||
if (downloadFile.song == song) {
|
if (downloadFile.track == song) {
|
||||||
return downloadFile
|
return downloadFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (downloadFile in activelyDownloading) {
|
for (downloadFile in activelyDownloading) {
|
||||||
if (downloadFile.song == song) {
|
if (downloadFile.track == song) {
|
||||||
return downloadFile
|
return downloadFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (downloadFile in downloadQueue) {
|
for (downloadFile in downloadQueue) {
|
||||||
if (downloadFile.song == song) {
|
if (downloadFile.track == song) {
|
||||||
return downloadFile
|
return downloadFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ class LocalMediaPlayer : KoinComponent {
|
|||||||
val playerDuration: Int
|
val playerDuration: Int
|
||||||
get() {
|
get() {
|
||||||
if (currentPlaying != null) {
|
if (currentPlaying != null) {
|
||||||
val duration = currentPlaying!!.song.duration
|
val duration = currentPlaying!!.track.duration
|
||||||
if (duration != null) {
|
if (duration != null) {
|
||||||
return duration * 1000
|
return duration * 1000
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ class LocalMediaPlayer : KoinComponent {
|
|||||||
setPlayerState(PlayerState.PREPARING, downloadFile)
|
setPlayerState(PlayerState.PREPARING, downloadFile)
|
||||||
|
|
||||||
mediaPlayer.setOnBufferingUpdateListener { mp, percent ->
|
mediaPlayer.setOnBufferingUpdateListener { mp, percent ->
|
||||||
val song = downloadFile.song
|
val song = downloadFile.track
|
||||||
|
|
||||||
if (percent == 100) {
|
if (percent == 100) {
|
||||||
mp.setOnBufferingUpdateListener(null)
|
mp.setOnBufferingUpdateListener(null)
|
||||||
@ -512,8 +512,8 @@ class LocalMediaPlayer : KoinComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var duration = 0
|
var duration = 0
|
||||||
if (downloadFile.song.duration != null) {
|
if (downloadFile.track.duration != null) {
|
||||||
duration = downloadFile.song.duration!! * 1000
|
duration = downloadFile.track.duration!! * 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaPlayer.setOnCompletionListener(object : OnCompletionListener {
|
mediaPlayer.setOnCompletionListener(object : OnCompletionListener {
|
||||||
|
@ -453,7 +453,7 @@ class MediaPlayerController(
|
|||||||
|
|
||||||
fun toggleSongStarred() {
|
fun toggleSongStarred() {
|
||||||
if (localMediaPlayer.currentPlaying == null) return
|
if (localMediaPlayer.currentPlaying == null) return
|
||||||
val song = localMediaPlayer.currentPlaying!!.song
|
val song = localMediaPlayer.currentPlaying!!.track
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
val musicService = getMusicService()
|
val musicService = getMusicService()
|
||||||
@ -477,7 +477,7 @@ class MediaPlayerController(
|
|||||||
fun setSongRating(rating: Int) {
|
fun setSongRating(rating: Int) {
|
||||||
if (!Settings.useFiveStarRating) return
|
if (!Settings.useFiveStarRating) return
|
||||||
if (localMediaPlayer.currentPlaying == null) return
|
if (localMediaPlayer.currentPlaying == null) return
|
||||||
val song = localMediaPlayer.currentPlaying!!.song
|
val song = localMediaPlayer.currentPlaying!!.track
|
||||||
song.userRating = rating
|
song.userRating = rating
|
||||||
Thread {
|
Thread {
|
||||||
try {
|
try {
|
||||||
|
@ -364,7 +364,7 @@ class MediaPlayerService : Service() {
|
|||||||
Settings.isNotificationAlwaysEnabled
|
Settings.isNotificationAlwaysEnabled
|
||||||
|
|
||||||
val show = playerState === PlayerState.STARTED || showWhenPaused
|
val show = playerState === PlayerState.STARTED || showWhenPaused
|
||||||
val song = currentPlaying?.song
|
val song = currentPlaying?.track
|
||||||
|
|
||||||
if (isStateChanged) {
|
if (isStateChanged) {
|
||||||
when {
|
when {
|
||||||
@ -396,7 +396,7 @@ class MediaPlayerService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isTrackChanged) {
|
if (isTrackChanged) {
|
||||||
Util.broadcastNewTrackInfo(this@MediaPlayerService, currentPlaying?.song)
|
Util.broadcastNewTrackInfo(this@MediaPlayerService, currentPlaying?.track)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update widget
|
// Update widget
|
||||||
@ -424,7 +424,7 @@ class MediaPlayerService : Service() {
|
|||||||
val index = downloader.currentPlayingIndex
|
val index = downloader.currentPlayingIndex
|
||||||
|
|
||||||
if (currentPlaying != null) {
|
if (currentPlaying != null) {
|
||||||
val song = currentPlaying.song
|
val song = currentPlaying.track
|
||||||
if (song.bookmarkPosition > 0 && Settings.shouldClearBookmark) {
|
if (song.bookmarkPosition > 0 && Settings.shouldClearBookmark) {
|
||||||
val musicService = getMusicService()
|
val musicService = getMusicService()
|
||||||
try {
|
try {
|
||||||
@ -523,7 +523,7 @@ class MediaPlayerService : Service() {
|
|||||||
|
|
||||||
// Init
|
// Init
|
||||||
val context = applicationContext
|
val context = applicationContext
|
||||||
val song = currentPlaying?.song
|
val song = currentPlaying?.track
|
||||||
val stopIntent = Util.getPendingIntentForMediaAction(
|
val stopIntent = Util.getPendingIntentForMediaAction(
|
||||||
context,
|
context,
|
||||||
KeyEvent.KEYCODE_MEDIA_STOP,
|
KeyEvent.KEYCODE_MEDIA_STOP,
|
||||||
|
@ -61,7 +61,7 @@ class PlaybackStateSerializer : KoinComponent {
|
|||||||
val state = State()
|
val state = State()
|
||||||
|
|
||||||
for (downloadFile in songs) {
|
for (downloadFile in songs) {
|
||||||
state.songs.add(downloadFile.song)
|
state.songs.add(downloadFile.track)
|
||||||
}
|
}
|
||||||
|
|
||||||
state.currentPlayingIndex = currentPlayingIndex
|
state.currentPlayingIndex = currentPlayingIndex
|
||||||
|
@ -188,7 +188,7 @@ class MediaSessionHandler : KoinComponent {
|
|||||||
val metadata = MediaMetadataCompat.Builder()
|
val metadata = MediaMetadataCompat.Builder()
|
||||||
if (currentPlaying != null) {
|
if (currentPlaying != null) {
|
||||||
try {
|
try {
|
||||||
val song = currentPlaying.song
|
val song = currentPlaying.track
|
||||||
val cover = BitmapUtils.getAlbumArtBitmapFromDisk(
|
val cover = BitmapUtils.getAlbumArtBitmapFromDisk(
|
||||||
song, Util.getMinDisplayMetric()
|
song, Util.getMinDisplayMetric()
|
||||||
)
|
)
|
||||||
@ -278,7 +278,7 @@ class MediaSessionHandler : KoinComponent {
|
|||||||
|
|
||||||
val queue = playlist.mapIndexed { id, file ->
|
val queue = playlist.mapIndexed { id, file ->
|
||||||
MediaSessionCompat.QueueItem(
|
MediaSessionCompat.QueueItem(
|
||||||
Util.getMediaDescriptionForEntry(file.song),
|
Util.getMediaDescriptionForEntry(file.track),
|
||||||
id.toLong()
|
id.toLong()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ object Util {
|
|||||||
|
|
||||||
var song: MusicDirectory.Track? = null
|
var song: MusicDirectory.Track? = null
|
||||||
val avrcpIntent = Intent(CM_AVRCP_METADATA_CHANGED)
|
val avrcpIntent = Intent(CM_AVRCP_METADATA_CHANGED)
|
||||||
if (currentPlaying != null) song = currentPlaying.song
|
if (currentPlaying != null) song = currentPlaying.track
|
||||||
|
|
||||||
fillIntent(avrcpIntent, song, playerPosition, id, listSize)
|
fillIntent(avrcpIntent, song, playerPosition, id, listSize)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user