Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC-Android
Commits
831db6c4
Commit
831db6c4
authored
Mar 10, 2019
by
Shivansh Saini
Committed by
Geoffrey Métais
Mar 12, 2019
Browse files
Close button in notification to stop unpausable media.
Fixes
#181
parent
14045a75
Changes
2
Hide whitespace changes
Inline
Side-by-side
vlc-android/src/org/videolan/vlc/PlaybackService.kt
View file @
831db6c4
...
...
@@ -569,7 +569,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
val
notification
=
if
(
this
::
notification
.
isInitialized
&&
!
stopped
)
notification
else
NotificationHelper
.
createPlaybackNotification
(
ctx
,
false
,
ctx
.
resources
.
getString
(
R
.
string
.
loading
),
""
,
""
,
null
,
false
,
mediaSession
.
sessionToken
,
sessionPendingIntent
)
false
,
true
,
mediaSession
.
sessionToken
,
sessionPendingIntent
)
startForeground
(
3
,
notification
)
isForeground
=
true
if
(
isVideoPlaying
||
AndroidDevices
.
showTvUi
(
this
)
||
stopped
)
hideNotification
(
true
)
...
...
@@ -661,6 +661,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
if
(
mw
!=
null
)
{
val
coverOnLockscreen
=
settings
.
getBoolean
(
"lockscreen_cover"
,
true
)
val
playing
=
isPlaying
val
pausable
=
isPausable
&&
isSeekable
&&
length
>
0
// TODO: length > 0 is temporarily hack till libVlc is fixed.
val
sessionToken
=
mediaSession
.
sessionToken
val
ctx
=
this
val
metaData
=
mediaSession
.
controller
.
metadata
...
...
@@ -680,7 +681,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
notification
=
NotificationHelper
.
createPlaybackNotification
(
ctx
,
mw
.
hasFlag
(
MediaWrapper
.
MEDIA_FORCE_AUDIO
),
title
,
artist
,
album
,
cover
,
playing
,
sessionToken
,
sessionPendingIntent
)
cover
,
playing
,
pausable
,
sessionToken
,
sessionPendingIntent
)
if
(
isPlayingPopup
)
return
@launch
if
(!
AndroidUtil
.
isLolliPopOrLater
||
playing
||
audioFocusHelper
.
lossTransient
)
{
if
(!
isForeground
)
{
...
...
vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
View file @
831db6c4
...
...
@@ -50,7 +50,7 @@ public class NotificationHelper {
public
static
final
String
VLC_DEBUG_CHANNEL
=
"vlc_debug"
;
public
static
Notification
createPlaybackNotification
(
Context
ctx
,
boolean
video
,
String
title
,
String
artist
,
String
album
,
Bitmap
cover
,
boolean
playing
,
String
album
,
Bitmap
cover
,
boolean
playing
,
boolean
pausable
,
MediaSessionCompat
.
Token
sessionToken
,
PendingIntent
spi
)
{
...
...
@@ -70,17 +70,20 @@ public class NotificationHelper {
.
setDeleteIntent
(
piStop
)
.
setContentIntent
(
spi
)
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_previous_w
,
ctx
.
getString
(
R
.
string
.
previous
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_SKIP_TO_PREVIOUS
)));
if
(
playing
)
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_pause_w
,
ctx
.
getString
(
R
.
string
.
pause
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_PLAY_PAUSE
)));
else
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_play_w
,
ctx
.
getString
(
R
.
string
.
play
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_PLAY_PAUSE
)));
R
.
drawable
.
ic_widget_previous_w
,
ctx
.
getString
(
R
.
string
.
previous
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_SKIP_TO_PREVIOUS
)));
if
(
pausable
)
{
if
(
playing
)
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_pause_w
,
ctx
.
getString
(
R
.
string
.
pause
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_PLAY_PAUSE
)));
else
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_play_w
,
ctx
.
getString
(
R
.
string
.
play
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
PlaybackStateCompat
.
ACTION_PLAY_PAUSE
)));
}
else
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_close_w
,
ctx
.
getString
(
R
.
string
.
stop
),
piStop
));
builder
.
addAction
(
new
NotificationCompat
.
Action
(
R
.
drawable
.
ic_widget_next_w
,
ctx
.
getString
(
R
.
string
.
next
),
MediaButtonReceiver
.
buildMediaButtonPendingIntent
(
ctx
,
...
...
@@ -89,7 +92,7 @@ public class NotificationHelper {
if
(
AndroidDevices
.
showMediaStyle
)
{
builder
.
setStyle
(
new
androidx
.
media
.
app
.
NotificationCompat
.
MediaStyle
()
.
setMediaSession
(
sessionToken
)
.
setShowActionsInCompactView
(
0
,
1
,
2
)
.
setShowActionsInCompactView
(
0
,
1
,
2
)
.
setShowCancelButton
(
true
)
.
setCancelButtonIntent
(
piStop
)
);
...
...
@@ -99,6 +102,7 @@ public class NotificationHelper {
private
static
NotificationCompat
.
Builder
scanCompatBuilder
;
private
static
final
Intent
notificationIntent
=
new
Intent
();
public
static
Notification
createScanNotification
(
Context
ctx
,
String
progressText
,
boolean
updateActions
,
boolean
paused
)
{
if
(
scanCompatBuilder
==
null
)
{
scanCompatBuilder
=
new
NotificationCompat
.
Builder
(
ctx
,
"vlc_medialibrary"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment