mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-05-15 23:06:35 +03:00
Fix insertAfterCurrent, Fix getUri
This commit is contained in:
parent
dd65a12b53
commit
46fb7664c3
@ -138,6 +138,8 @@ open class APIDataSource private constructor(
|
||||
val bitrate = components[1].toInt()
|
||||
|
||||
Timber.i("DATASOURCE: %s", "Start")
|
||||
// FIXME
|
||||
// WRONG API CLIENT
|
||||
val request = subsonicAPIClient.api.stream(id, bitrate, offset = 0)
|
||||
val response: retrofit2.Response<ResponseBody>?
|
||||
val streamResponse: StreamResponse
|
||||
|
@ -107,7 +107,6 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
private val useId3Tags get() = Settings.shouldUseId3Tags
|
||||
private val musicFolderId get() = activeServerProvider.getActiveServer().musicFolderId
|
||||
|
||||
|
||||
/**
|
||||
* Called when a {@link MediaBrowser} requests the root {@link MediaItem} by {@link
|
||||
* MediaBrowser#getLibraryRoot(LibraryParams)}.
|
||||
@ -162,7 +161,9 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||
playFromMediaId(mediaId)
|
||||
|
||||
// TODO: Later
|
||||
// FIXME:
|
||||
// Create LRU Cache of MediaItems, fill it in the other calls
|
||||
// and retrieve it here.
|
||||
return Futures.immediateFuture(
|
||||
LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE)
|
||||
)
|
||||
@ -215,7 +216,6 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("ReturnCount", "ComplexMethod")
|
||||
fun onLoadChildren(
|
||||
parentId: String,
|
||||
@ -300,7 +300,6 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("MagicNumber", "ComplexMethod")
|
||||
private fun playFromMediaId(mediaId: String?) {
|
||||
Timber.d(
|
||||
@ -1083,7 +1082,6 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun buildMediaItemFromTrack(
|
||||
track: Track,
|
||||
mediaId: String,
|
||||
@ -1129,5 +1127,4 @@ class AutoMediaBrowserCallback(var player: Player) :
|
||||
.setUri(sourceUri)
|
||||
.build()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +147,12 @@ class CachedDataSource(
|
||||
return read
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called by StatsDataSource to verify that the loading succeeded,
|
||||
* so its important that we return the correct value here..
|
||||
*/
|
||||
override fun getUri(): Uri? {
|
||||
return cachePath?.toUri()
|
||||
return cachePath?.toUri() ?: upstreamDataSource.uri
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
@ -174,6 +178,7 @@ class CachedDataSource(
|
||||
if (!found) return -1
|
||||
|
||||
cachePath = filePath
|
||||
openedFile = true
|
||||
|
||||
cacheFile = Storage.getFromPath(filePath)!!
|
||||
responseByteStream = cacheFile!!.getFileInputStream()
|
||||
|
@ -399,11 +399,11 @@ class Downloader(
|
||||
val fileLength = Storage.getFromPath(downloadFile.partialFile)?.length ?: 0
|
||||
|
||||
needsDownloading = (
|
||||
downloadFile.desiredBitRate == 0 ||
|
||||
duration == null ||
|
||||
duration == 0 ||
|
||||
fileLength == 0L
|
||||
)
|
||||
downloadFile.desiredBitRate == 0 ||
|
||||
duration == null ||
|
||||
duration == 0 ||
|
||||
fileLength == 0L
|
||||
)
|
||||
|
||||
if (needsDownloading) {
|
||||
// Attempt partial HTTP GET, appending to the file if it exists.
|
||||
|
@ -366,7 +366,7 @@ class MediaPlayerController(
|
||||
when (insertionMode) {
|
||||
InsertionMode.CLEAR -> clear()
|
||||
InsertionMode.APPEND -> insertAt = mediaItemCount
|
||||
InsertionMode.AFTER_CURRENT -> insertAt = currentMediaItemIndex
|
||||
InsertionMode.AFTER_CURRENT -> insertAt = currentMediaItemIndex + 1
|
||||
}
|
||||
|
||||
val mediaItems: List<MediaItem> = songs.map {
|
||||
|
@ -109,10 +109,10 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
|
||||
val autoStart =
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY ||
|
||||
keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_NEXT
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY ||
|
||||
keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS ||
|
||||
keyCode == KeyEvent.KEYCODE_MEDIA_NEXT
|
||||
|
||||
// We can receive intents (e.g. MediaButton) when everything is stopped, so we need to start
|
||||
onCreate(autoStart) {
|
||||
@ -149,10 +149,10 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
return
|
||||
|
||||
val autoStart = action == Constants.CMD_PLAY ||
|
||||
action == Constants.CMD_RESUME_OR_PLAY ||
|
||||
action == Constants.CMD_TOGGLEPAUSE ||
|
||||
action == Constants.CMD_PREVIOUS ||
|
||||
action == Constants.CMD_NEXT
|
||||
action == Constants.CMD_RESUME_OR_PLAY ||
|
||||
action == Constants.CMD_TOGGLEPAUSE ||
|
||||
action == Constants.CMD_PREVIOUS ||
|
||||
action == Constants.CMD_NEXT
|
||||
|
||||
// We can receive intents when everything is stopped, so we need to start
|
||||
onCreate(autoStart) {
|
||||
|
@ -39,8 +39,8 @@ class DownloadHandler(
|
||||
val onValid = Runnable {
|
||||
// TODO: The logic here is different than in the controller...
|
||||
val insertionMode = when {
|
||||
append -> MediaPlayerController.InsertionMode.APPEND
|
||||
playNext -> MediaPlayerController.InsertionMode.AFTER_CURRENT
|
||||
append -> MediaPlayerController.InsertionMode.APPEND
|
||||
else -> MediaPlayerController.InsertionMode.CLEAR
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,6 @@ import android.view.Gravity
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.AnyRes
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.app.UApp.Companion.applicationContext
|
||||
import org.moire.ultrasonic.domain.Bookmark
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
import org.moire.ultrasonic.domain.SearchResult
|
||||
import org.moire.ultrasonic.domain.Track
|
||||
import timber.log.Timber
|
||||
import java.io.Closeable
|
||||
import java.io.UnsupportedEncodingException
|
||||
import java.security.MessageDigest
|
||||
@ -49,6 +42,13 @@ import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.app.UApp.Companion.applicationContext
|
||||
import org.moire.ultrasonic.domain.Bookmark
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
import org.moire.ultrasonic.domain.SearchResult
|
||||
import org.moire.ultrasonic.domain.Track
|
||||
import timber.log.Timber
|
||||
|
||||
private const val LINE_LENGTH = 60
|
||||
private const val DEGRADE_PRECISION_AFTER = 10
|
||||
@ -509,7 +509,7 @@ object Util {
|
||||
val hours = TimeUnit.MILLISECONDS.toHours(millis)
|
||||
val minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(hours)
|
||||
val seconds = TimeUnit.MILLISECONDS.toSeconds(millis) -
|
||||
TimeUnit.MINUTES.toSeconds(hours * MINUTES_IN_HOUR + minutes)
|
||||
TimeUnit.MINUTES.toSeconds(hours * MINUTES_IN_HOUR + minutes)
|
||||
|
||||
return when {
|
||||
hours >= DEGRADE_PRECISION_AFTER -> {
|
||||
@ -603,9 +603,9 @@ object Util {
|
||||
fun getUriToDrawable(context: Context, @AnyRes drawableId: Int): Uri {
|
||||
return Uri.parse(
|
||||
ContentResolver.SCHEME_ANDROID_RESOURCE +
|
||||
"://" + context.resources.getResourcePackageName(drawableId) +
|
||||
'/' + context.resources.getResourceTypeName(drawableId) +
|
||||
'/' + context.resources.getResourceEntryName(drawableId)
|
||||
"://" + context.resources.getResourcePackageName(drawableId) +
|
||||
'/' + context.resources.getResourceTypeName(drawableId) +
|
||||
'/' + context.resources.getResourceEntryName(drawableId)
|
||||
)
|
||||
}
|
||||
|
||||
@ -643,8 +643,8 @@ object Util {
|
||||
|
||||
if (artistName != null) {
|
||||
if (Settings.shouldDisplayBitrateWithArtist && (
|
||||
!bitRate.isNullOrBlank() || !fileFormat.isNullOrBlank()
|
||||
)
|
||||
!bitRate.isNullOrBlank() || !fileFormat.isNullOrBlank()
|
||||
)
|
||||
) {
|
||||
artist.append(artistName).append(" (").append(
|
||||
String.format(
|
||||
|
Loading…
x
Reference in New Issue
Block a user