Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Geoffrey Métais
VLC-Android
Commits
7340ca33
Commit
7340ca33
authored
May 03, 2018
by
Geoffrey Métais
Browse files
Stop service if loadLastPlaylist fails
parent
85eca846
Changes
2
Hide whitespace changes
Inline
Side-by-side
vlc-android/src/org/videolan/vlc/PlaybackService.kt
View file @
7340ca33
...
...
@@ -959,9 +959,9 @@ class PlaybackService : MediaBrowserServiceCompat() {
private
fun
loadLastAudioPlaylist
()
{
if
(
AndroidDevices
.
isAndroidTv
)
return
if
(
medialibrary
.
isInitiated
&&
libraryReceiver
==
null
)
playlistManager
.
loadLastPlaylist
(
Constants
.
PLAYLIST_TYPE_AUDIO
)
if
(!
playlistManager
.
loadLastPlaylist
(
Constants
.
PLAYLIST_TYPE_AUDIO
)
)
stopSelf
()
else
registerMedialibrary
(
Runnable
{
playlistManager
.
loadLastPlaylist
(
Constants
.
PLAYLIST_TYPE_AUDIO
)
})
registerMedialibrary
(
Runnable
{
if
(!
playlistManager
.
loadLastPlaylist
(
Constants
.
PLAYLIST_TYPE_AUDIO
)
)
stopSelf
()
})
}
fun
loadLastPlaylist
(
type
:
Int
)
{
...
...
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
View file @
7340ca33
...
...
@@ -20,6 +20,7 @@ import org.videolan.medialibrary.media.MediaWrapper
import
org.videolan.vlc.BuildConfig
import
org.videolan.vlc.PlaybackService
import
org.videolan.vlc.R
import
org.videolan.vlc.R.string.audio
import
org.videolan.vlc.VLCApplication
import
org.videolan.vlc.gui.preferences.PreferencesActivity
import
org.videolan.vlc.gui.preferences.PreferencesFragment
...
...
@@ -118,18 +119,24 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
@Volatile
private
var
loadingLastPlaylist
=
false
fun
loadLastPlaylist
(
type
:
Int
)
{
if
(
loadingLastPlaylist
)
return
fun
loadLastPlaylist
(
type
:
Int
)
:
Boolean
{
if
(
loadingLastPlaylist
)
return
true
loadingLastPlaylist
=
true
val
audio
=
type
==
Constants
.
PLAYLIST_TYPE_AUDIO
val
currentMedia
=
settings
.
getString
(
if
(
audio
)
"current_song"
else
"current_media"
,
""
)
if
(
currentMedia
.
isEmpty
())
{
loadingLastPlaylist
=
false
return
false
}
val
locations
=
settings
.
getString
(
if
(
audio
)
"audio_list"
else
"media_list"
,
""
).
split
(
" "
.
toRegex
()).
dropLastWhile
({
it
.
isEmpty
()
}).
toTypedArray
()
if
(
Util
.
isArrayEmpty
(
locations
))
{
loadingLastPlaylist
=
false
return
false
}
launch
(
UI
,
CoroutineStart
.
UNDISPATCHED
)
{
val
audio
=
type
==
Constants
.
PLAYLIST_TYPE_AUDIO
val
currentMedia
=
settings
.
getString
(
if
(
audio
)
"current_song"
else
"current_media"
,
""
)
if
(
""
==
currentMedia
)
return
@launch
val
locations
=
settings
.
getString
(
if
(
audio
)
"audio_list"
else
"media_list"
,
""
).
split
(
" "
.
toRegex
()).
dropLastWhile
({
it
.
isEmpty
()
}).
toTypedArray
()
if
(
Util
.
isArrayEmpty
(
locations
))
return
@launch
val
playList
=
async
{
val
playList
=
withContext
(
CommonPool
)
{
locations
.
map
{
Uri
.
decode
(
it
)
}.
mapTo
(
ArrayList
(
locations
.
size
))
{
MediaWrapper
(
Uri
.
parse
(
it
))
}
}
.
await
()
}
// load playlist
shuffling
=
settings
.
getBoolean
(
if
(
audio
)
"audio_shuffling"
else
"media_shuffling"
,
false
)
repeating
=
settings
.
getInt
(
if
(
audio
)
"audio_repeating"
else
"media_repeating"
,
Constants
.
REPEAT_NONE
)
...
...
@@ -145,6 +152,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
load
(
playList
,
position
)
loadingLastPlaylist
=
false
}
return
true
}
private
fun
onPlaylistLoaded
()
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment