mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
minor improvements
This commit is contained in:
parent
0db7821418
commit
c835f5ab80
@ -687,6 +687,9 @@ class PlayerFragment : BaseFragment() {
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
try {
|
||||
// clear the playing queue
|
||||
PlayingQueue.clear()
|
||||
|
||||
saveWatchPosition()
|
||||
nowPlayingNotification.destroy()
|
||||
activity?.requestedOrientation =
|
||||
|
@ -333,6 +333,9 @@ class BackgroundMode : Service() {
|
||||
* destroy the [BackgroundMode] foreground service
|
||||
*/
|
||||
override fun onDestroy() {
|
||||
// clear the playing queue
|
||||
PlayingQueue.clear()
|
||||
|
||||
// called when the user pressed stop in the notification
|
||||
// stop the service from being in the foreground and remove the notification
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
@ -1,13 +1,9 @@
|
||||
package com.github.libretube.sheets
|
||||
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
||||
import com.github.libretube.dialogs.AddToPlaylistDialog
|
||||
import com.github.libretube.dialogs.DownloadDialog
|
||||
import com.github.libretube.dialogs.ShareDialog
|
||||
@ -44,18 +40,9 @@ class VideoOptionsBottomSheet(
|
||||
/**
|
||||
* Check whether the player is running by observing the notification
|
||||
*/
|
||||
try {
|
||||
val notificationManager =
|
||||
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
notificationManager.activeNotifications.forEach {
|
||||
if (it.id == PLAYER_NOTIFICATION_ID) {
|
||||
optionsList += context?.getString(R.string.add_to_queue)!!
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
if (PlayingQueue.isNotEmpty()) {
|
||||
optionsList += context?.getString(R.string.play_next)!!
|
||||
optionsList += context?.getString(R.string.add_to_queue)!!
|
||||
}
|
||||
|
||||
setSimpleItems(optionsList) { which ->
|
||||
|
@ -166,6 +166,7 @@ class NowPlayingNotification(
|
||||
Context.NOTIFICATION_SERVICE
|
||||
) as NotificationManager
|
||||
notificationManager.cancel(PLAYER_NOTIFICATION_ID)
|
||||
player.stop()
|
||||
player.release()
|
||||
}
|
||||
}
|
||||
|
@ -51,4 +51,6 @@ object PlayingQueue {
|
||||
currentVideoId = videoId
|
||||
if (!contains(videoId)) add(videoId)
|
||||
}
|
||||
|
||||
fun isNotEmpty() = queue.isNotEmpty()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user