Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
831db6c4
Commit
831db6c4
authored
5 years ago
by
Shivansh Saini
Committed by
Geoffrey Métais
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Close button in notification to stop unpausable media.
Fixes
#181
parent
14045a75
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/PlaybackService.kt
+3
-2
3 additions, 2 deletions
vlc-android/src/org/videolan/vlc/PlaybackService.kt
vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
+17
-13
17 additions, 13 deletions
.../src/org/videolan/vlc/gui/helpers/NotificationHelper.java
with
20 additions
and
15 deletions
vlc-android/src/org/videolan/vlc/PlaybackService.kt
+
3
−
2
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
)
{
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.java
+
17
−
13
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"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment