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() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
try {
|
try {
|
||||||
|
// clear the playing queue
|
||||||
|
PlayingQueue.clear()
|
||||||
|
|
||||||
saveWatchPosition()
|
saveWatchPosition()
|
||||||
nowPlayingNotification.destroy()
|
nowPlayingNotification.destroy()
|
||||||
activity?.requestedOrientation =
|
activity?.requestedOrientation =
|
||||||
|
@ -333,6 +333,9 @@ class BackgroundMode : Service() {
|
|||||||
* destroy the [BackgroundMode] foreground service
|
* destroy the [BackgroundMode] foreground service
|
||||||
*/
|
*/
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
// clear the playing queue
|
||||||
|
PlayingQueue.clear()
|
||||||
|
|
||||||
// called when the user pressed stop in the notification
|
// called when the user pressed stop in the notification
|
||||||
// stop the service from being in the foreground and remove the notification
|
// stop the service from being in the foreground and remove the notification
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package com.github.libretube.sheets
|
package com.github.libretube.sheets
|
||||||
|
|
||||||
import android.app.NotificationManager
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.constants.IntentData
|
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.AddToPlaylistDialog
|
||||||
import com.github.libretube.dialogs.DownloadDialog
|
import com.github.libretube.dialogs.DownloadDialog
|
||||||
import com.github.libretube.dialogs.ShareDialog
|
import com.github.libretube.dialogs.ShareDialog
|
||||||
@ -44,18 +40,9 @@ class VideoOptionsBottomSheet(
|
|||||||
/**
|
/**
|
||||||
* Check whether the player is running by observing the notification
|
* Check whether the player is running by observing the notification
|
||||||
*/
|
*/
|
||||||
try {
|
if (PlayingQueue.isNotEmpty()) {
|
||||||
val notificationManager =
|
optionsList += context?.getString(R.string.play_next)!!
|
||||||
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
optionsList += context?.getString(R.string.add_to_queue)!!
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSimpleItems(optionsList) { which ->
|
setSimpleItems(optionsList) { which ->
|
||||||
|
@ -166,6 +166,7 @@ class NowPlayingNotification(
|
|||||||
Context.NOTIFICATION_SERVICE
|
Context.NOTIFICATION_SERVICE
|
||||||
) as NotificationManager
|
) as NotificationManager
|
||||||
notificationManager.cancel(PLAYER_NOTIFICATION_ID)
|
notificationManager.cancel(PLAYER_NOTIFICATION_ID)
|
||||||
|
player.stop()
|
||||||
player.release()
|
player.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,4 +51,6 @@ object PlayingQueue {
|
|||||||
currentVideoId = videoId
|
currentVideoId = videoId
|
||||||
if (!contains(videoId)) add(videoId)
|
if (!contains(videoId)) add(videoId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isNotEmpty() = queue.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user