Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
528
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
eb846cff
Commit
eb846cff
authored
7 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Reduce calls of startService in PlaybackService
parent
8ee4529d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/PlaybackService.java
+23
-8
23 additions, 8 deletions
vlc-android/src/org/videolan/vlc/PlaybackService.java
with
23 additions
and
8 deletions
vlc-android/src/org/videolan/vlc/PlaybackService.java
+
23
−
8
View file @
eb846cff
...
@@ -242,7 +242,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -242,7 +242,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
hideNotification
();
mSettings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
mSettings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
mMediaPlayer
=
newMediaPlayer
();
mMediaPlayer
=
newMediaPlayer
();
mMediaPlayer
.
setEqualizer
(
VLCOptions
.
getEqualizerSetFromSettings
(
this
));
mMediaPlayer
.
setEqualizer
(
VLCOptions
.
getEqualizerSetFromSettings
(
this
));
...
@@ -353,7 +352,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -353,7 +352,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@Override
@Override
public
void
onDestroy
()
{
public
void
onDestroy
()
{
super
.
onDestroy
();
super
.
onDestroy
();
stop
();
stop
(
true
);
if
(
mMediaSession
!=
null
)
{
if
(
mMediaSession
!=
null
)
{
mMediaSession
.
setActive
(
false
);
mMediaSession
.
setActive
(
false
);
mMediaSession
.
release
();
mMediaSession
.
release
();
...
@@ -719,7 +718,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -719,7 +718,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mMedialibrary
.
resumeBackgroundOperations
();
mMedialibrary
.
resumeBackgroundOperations
();
mStopped
=
true
;
mStopped
=
true
;
mCurrentIndex
=
-
1
;
mCurrentIndex
=
-
1
;
hideNotification
();
executeUpdate
();
executeUpdate
();
publishState
();
publishState
();
executeUpdateProgress
();
executeUpdateProgress
();
...
@@ -967,10 +965,17 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -967,10 +965,17 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
cover
,
playing
,
sessionToken
,
getSessionPendingIntent
());
cover
,
playing
,
sessionToken
,
getSessionPendingIntent
());
if
(
isPlayingPopup
())
if
(
isPlayingPopup
())
return
;
return
;
if
(
AndroidUtil
.
isOOrLater
||
!
AndroidUtil
.
isLolliPopOrLater
||
playing
)
if
(
AndroidUtil
.
isOOrLater
||
!
AndroidUtil
.
isLolliPopOrLater
||
playing
)
{
PlaybackService
.
this
.
startForeground
(
3
,
notification
);
if
(!
mIsForeground
)
{
else
{
PlaybackService
.
this
.
startForeground
(
3
,
notification
);
PlaybackService
.
this
.
stopForeground
(
false
);
mIsForeground
=
true
;
}
else
NotificationManagerCompat
.
from
(
ctx
).
notify
(
3
,
notification
);
}
else
{
if
(
mIsForeground
)
{
PlaybackService
.
this
.
stopForeground
(
false
);
mIsForeground
=
false
;
}
NotificationManagerCompat
.
from
(
ctx
).
notify
(
3
,
notification
);
NotificationManagerCompat
.
from
(
ctx
).
notify
(
3
,
notification
);
}
}
}
catch
(
IllegalArgumentException
e
){
}
catch
(
IllegalArgumentException
e
){
...
@@ -999,12 +1004,15 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -999,12 +1004,15 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
}
}
}
}
private
volatile
boolean
mIsForeground
=
false
;
private
void
hideNotification
()
{
private
void
hideNotification
()
{
mExecutorService
.
execute
(
new
Runnable
()
{
mExecutorService
.
execute
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(!
isPlayingPopup
()
)
if
(!
isPlayingPopup
()
&&
mIsForeground
)
{
PlaybackService
.
this
.
stopForeground
(
true
);
PlaybackService
.
this
.
stopForeground
(
true
);
mIsForeground
=
false
;
}
NotificationManagerCompat
.
from
(
PlaybackService
.
this
).
cancel
(
3
);
NotificationManagerCompat
.
from
(
PlaybackService
.
this
).
cancel
(
3
);
}
}
});
});
...
@@ -1026,6 +1034,11 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -1026,6 +1034,11 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@MainThread
@MainThread
public
void
stop
()
{
public
void
stop
()
{
stop
(
false
);
}
@MainThread
public
void
stop
(
boolean
systemExit
)
{
removePopup
();
removePopup
();
if
(
mMediaPlayer
==
null
)
if
(
mMediaPlayer
==
null
)
return
;
return
;
...
@@ -1041,6 +1054,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
...
@@ -1041,6 +1054,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mPrevious
.
clear
();
mPrevious
.
clear
();
mHandler
.
removeMessages
(
SHOW_PROGRESS
);
mHandler
.
removeMessages
(
SHOW_PROGRESS
);
onPlaybackStopped
();
onPlaybackStopped
();
if
(!
systemExit
)
hideNotification
();
}
}
private
void
determinePrevAndNextIndices
()
{
private
void
determinePrevAndNextIndices
()
{
...
...
This diff is collapsed.
Click to expand it.
Jean-Baptiste Kempf
@jbk
mentioned in issue
#386 (closed)
·
7 years ago
mentioned in issue
#386 (closed)
mentioned in issue #386
Toggle commit list
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