mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-03-12 01:20:12 +01:00
Fixed autoplay
Fixed uncaught exception Fixed playlist loading from file
This commit is contained in:
parent
24092ce465
commit
2847a51674
@ -15,4 +15,4 @@ abstract class ArtistOrIndex(
|
|||||||
open var albumCount: Long? = null,
|
open var albumCount: Long? = null,
|
||||||
@Ignore
|
@Ignore
|
||||||
open var closeness: Int = 0
|
open var closeness: Int = 0
|
||||||
) : GenericEntry(id)
|
) : GenericEntry()
|
||||||
|
@ -2,9 +2,8 @@ package org.moire.ultrasonic.domain
|
|||||||
|
|
||||||
import androidx.room.Ignore
|
import androidx.room.Ignore
|
||||||
|
|
||||||
open class GenericEntry(
|
abstract class GenericEntry : Identifiable {
|
||||||
@Ignore override val id: String
|
abstract override val id: String
|
||||||
) : Identifiable {
|
|
||||||
@Ignore
|
@Ignore
|
||||||
open val name: String? = null
|
open val name: String? = null
|
||||||
override fun compareTo(other: Identifiable): Int {
|
override fun compareTo(other: Identifiable): Int {
|
||||||
|
@ -69,7 +69,7 @@ class MusicDirectory {
|
|||||||
var bookmarkPosition: Int = 0,
|
var bookmarkPosition: Int = 0,
|
||||||
var userRating: Int? = null,
|
var userRating: Int? = null,
|
||||||
var averageRating: Float? = null
|
var averageRating: Float? = null
|
||||||
) : Serializable, GenericEntry(id) {
|
) : Serializable, GenericEntry() {
|
||||||
fun setDuration(duration: Long) {
|
fun setDuration(duration: Long) {
|
||||||
this.duration = duration.toInt()
|
this.duration = duration.toInt()
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,4 @@ import androidx.room.PrimaryKey
|
|||||||
data class MusicFolder(
|
data class MusicFolder(
|
||||||
@PrimaryKey override val id: String,
|
@PrimaryKey override val id: String,
|
||||||
override val name: String
|
override val name: String
|
||||||
) : GenericEntry(id)
|
) : GenericEntry()
|
||||||
|
@ -10,7 +10,7 @@ data class Playlist @JvmOverloads constructor(
|
|||||||
val songCount: String = "",
|
val songCount: String = "",
|
||||||
val created: String = "",
|
val created: String = "",
|
||||||
val public: Boolean? = null
|
val public: Boolean? = null
|
||||||
) : Serializable, GenericEntry(id) {
|
) : Serializable, GenericEntry() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val serialVersionUID = -4160515427075433798L
|
private const val serialVersionUID = -4160515427075433798L
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ data class PodcastsChannel(
|
|||||||
val url: String?,
|
val url: String?,
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val status: String?
|
val status: String?
|
||||||
) : Serializable, GenericEntry(id) {
|
) : Serializable, GenericEntry() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val serialVersionUID = -4160515427075433798L
|
private const val serialVersionUID = -4160515427075433798L
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ data class Share(
|
|||||||
var expires: String? = null,
|
var expires: String? = null,
|
||||||
var visitCount: Long? = null,
|
var visitCount: Long? = null,
|
||||||
private val entries: MutableList<Entry> = mutableListOf()
|
private val entries: MutableList<Entry> = mutableListOf()
|
||||||
) : Serializable, GenericEntry(id) {
|
) : Serializable, GenericEntry() {
|
||||||
override val name: String?
|
override val name: String?
|
||||||
get() {
|
get() {
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
|
@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.PriorityQueue
|
import java.util.PriorityQueue
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
import java.util.concurrent.RejectedExecutionException
|
||||||
import java.util.concurrent.ScheduledExecutorService
|
import java.util.concurrent.ScheduledExecutorService
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import org.koin.core.component.KoinComponent
|
import org.koin.core.component.KoinComponent
|
||||||
@ -91,10 +92,21 @@ class Downloader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkDownloads() {
|
fun checkDownloads() {
|
||||||
if (executorService == null || executorService!!.isTerminated) {
|
if (
|
||||||
|
executorService == null ||
|
||||||
|
executorService!!.isTerminated ||
|
||||||
|
executorService!!.isShutdown
|
||||||
|
) {
|
||||||
start()
|
start()
|
||||||
} else {
|
} else {
|
||||||
executorService?.execute(downloadChecker)
|
try {
|
||||||
|
executorService?.execute(downloadChecker)
|
||||||
|
} catch (exception: RejectedExecutionException) {
|
||||||
|
Timber.w(
|
||||||
|
exception,
|
||||||
|
"checkDownloads() can't run, maybe the Downloader is shutting down..."
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ import android.app.Service
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Handler
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import android.os.Looper
|
||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
@ -159,7 +161,10 @@ class MediaPlayerService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun notifyDownloaderStopped() {
|
fun notifyDownloaderStopped() {
|
||||||
stopIfIdle()
|
// TODO It would be nice to know if the service really can be stopped instead of just
|
||||||
|
// checking if it is idle once...
|
||||||
|
val handler = Handler(Looper.getMainLooper())
|
||||||
|
handler.postDelayed({ stopIfIdle() }, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@ -740,14 +745,16 @@ class MediaPlayerService : Service() {
|
|||||||
private const val NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service"
|
private const val NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service"
|
||||||
private const val NOTIFICATION_ID = 3033
|
private const val NOTIFICATION_ID = 3033
|
||||||
|
|
||||||
|
@Volatile
|
||||||
private var instance: MediaPlayerService? = null
|
private var instance: MediaPlayerService? = null
|
||||||
private val instanceLock = Any()
|
private val instanceLock = Any()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getInstance(): MediaPlayerService? {
|
fun getInstance(): MediaPlayerService? {
|
||||||
val context = UApp.applicationContext()
|
val context = UApp.applicationContext()
|
||||||
synchronized(instanceLock) {
|
for (i in 0..19) {
|
||||||
for (i in 0..19) {
|
if (instance != null) return instance
|
||||||
|
synchronized(instanceLock) {
|
||||||
if (instance != null) return instance
|
if (instance != null) return instance
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
context.startForegroundService(
|
context.startForegroundService(
|
||||||
@ -756,10 +763,10 @@ class MediaPlayerService : Service() {
|
|||||||
} else {
|
} else {
|
||||||
context.startService(Intent(context, MediaPlayerService::class.java))
|
context.startService(Intent(context, MediaPlayerService::class.java))
|
||||||
}
|
}
|
||||||
Util.sleepQuietly(50L)
|
|
||||||
}
|
}
|
||||||
return instance
|
Util.sleepQuietly(100L)
|
||||||
}
|
}
|
||||||
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user