Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Ewout ter Hoeven
VLC-Android
Commits
ae0047a9
Commit
ae0047a9
authored
Nov 25, 2011
by
John Mooring
Committed by
Sébastien Toque
Nov 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented repeat and shuffle.
Signed-off-by:
Sébastien Toque
<
xilasz@gmail.com
>
parent
74e49bf4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
14 deletions
+127
-14
vlc-android/res/drawable/ic_repeat_glow.png
vlc-android/res/drawable/ic_repeat_glow.png
+0
-0
vlc-android/res/drawable/ic_shuffle_glow.png
vlc-android/res/drawable/ic_shuffle_glow.png
+0
-0
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
+8
-0
vlc-android/src/org/videolan/vlc/android/AudioPlayerActivity.java
...oid/src/org/videolan/vlc/android/AudioPlayerActivity.java
+14
-4
vlc-android/src/org/videolan/vlc/android/AudioService.java
vlc-android/src/org/videolan/vlc/android/AudioService.java
+64
-10
vlc-android/src/org/videolan/vlc/android/AudioServiceController.java
.../src/org/videolan/vlc/android/AudioServiceController.java
+37
-0
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
+4
-0
No files found.
vlc-android/res/drawable/ic_repeat_glow.png
0 → 100644
View file @
ae0047a9
12.1 KB
vlc-android/res/drawable/ic_shuffle_glow.png
0 → 100644
View file @
ae0047a9
10.8 KB
vlc-android/src/org/videolan/vlc/android/AudioPlayer.java
View file @
ae0047a9
...
...
@@ -34,6 +34,14 @@ public interface AudioPlayer {
void
next
();
void
previous
();
void
shuffle
();
void
repeat
();
boolean
isShuffling
();
boolean
isRepeating
();
}
}
vlc-android/src/org/videolan/vlc/android/AudioPlayerActivity.java
View file @
ae0047a9
...
...
@@ -85,6 +85,16 @@ public class AudioPlayerActivity extends Activity implements AudioPlayer {
}
else
{
mPlayPause
.
setBackgroundResource
(
R
.
drawable
.
ic_play
);
}
if
(
mAudioController
.
isShuffling
())
{
mShuffle
.
setImageResource
(
R
.
drawable
.
ic_shuffle_glow
);
}
else
{
mShuffle
.
setImageResource
(
R
.
drawable
.
ic_shuffle
);
}
if
(
mAudioController
.
isRepeating
())
{
mRepeat
.
setImageResource
(
R
.
drawable
.
ic_repeat_glow
);
}
else
{
mRepeat
.
setImageResource
(
R
.
drawable
.
ic_repeat
);
}
if
(
mAudioController
.
hasNext
())
mNext
.
setVisibility
(
ImageButton
.
VISIBLE
);
else
...
...
@@ -137,13 +147,13 @@ public class AudioPlayerActivity extends Activity implements AudioPlayer {
}
public
void
onRepeatClick
(
View
view
)
{
//
mAudioController.repeat();
Util
.
toaster
(
R
.
string
.
notavailable
);
mAudioController
.
repeat
();
update
(
);
}
public
void
onShuffleClick
(
View
view
)
{
//
mAudioController.shuffle();
Util
.
toaster
(
R
.
string
.
notavailable
);
mAudioController
.
shuffle
();
update
(
);
}
@Override
...
...
vlc-android/src/org/videolan/vlc/android/AudioService.java
View file @
ae0047a9
...
...
@@ -2,6 +2,7 @@ package org.videolan.vlc.android;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Stack
;
import
android.app.Notification
;
import
android.app.PendingIntent
;
...
...
@@ -20,10 +21,14 @@ public class AudioService extends Service {
private
LibVLC
mLibVLC
;
private
ArrayList
<
Media
>
mMediaList
;
private
ArrayList
<
Media
>
mPlayedMedia
;
private
Stack
<
Media
>
mPrevious
;
private
Media
mCurrentMedia
;
private
ArrayList
<
IAudioServiceCallback
>
mCallback
;
private
EventManager
mEventManager
;
private
Notification
mNotification
;
private
boolean
mShuffling
=
false
;
private
boolean
mRepeating
=
false
;
@Override
public
void
onStart
(
Intent
intent
,
int
startId
)
{
...
...
@@ -38,6 +43,8 @@ public class AudioService extends Service {
mCallback
=
new
ArrayList
<
IAudioServiceCallback
>();
mMediaList
=
new
ArrayList
<
Media
>();
mPlayedMedia
=
new
ArrayList
<
Media
>();
mPrevious
=
new
Stack
<
Media
>();
mEventManager
=
EventManager
.
getIntance
();
}
...
...
@@ -144,6 +151,8 @@ public class AudioService extends Service {
mLibVLC
.
stop
();
mCurrentMedia
=
null
;
mMediaList
.
clear
();
mPlayedMedia
.
clear
();
mPrevious
.
clear
();
mHandler
.
removeMessages
(
SHOW_PROGRESS
);
hideNotification
();
executeUpdate
();
...
...
@@ -151,23 +160,43 @@ public class AudioService extends Service {
private
void
next
()
{
int
index
=
mMediaList
.
indexOf
(
mCurrentMedia
);
if
(
index
<
mMediaList
.
size
()
-
1
)
{
mPrevious
.
push
(
mCurrentMedia
);
if
(
mRepeating
)
mCurrentMedia
=
mMediaList
.
get
(
index
);
else
if
(
mShuffling
&&
mPlayedMedia
.
size
()
<
mMediaList
.
size
())
{
while
(
mPlayedMedia
.
contains
(
mCurrentMedia
=
mMediaList
.
get
((
int
)
(
Math
.
random
()
*
mMediaList
.
size
()))))
;
}
else
if
(
index
<
mMediaList
.
size
()
-
1
)
{
mCurrentMedia
=
mMediaList
.
get
(
index
+
1
);
mLibVLC
.
readMedia
(
mCurrentMedia
.
getPath
());
showNotification
();
}
else
{
stop
();
return
;
}
mLibVLC
.
readMedia
(
mCurrentMedia
.
getPath
());
showNotification
();
}
private
void
previous
()
{
int
index
=
mMediaList
.
indexOf
(
mCurrentMedia
);
if
(
index
>
0
)
{
if
(
mPrevious
.
size
()
>
0
)
mCurrentMedia
=
mPrevious
.
pop
();
else
if
(
index
>
0
)
mCurrentMedia
=
mMediaList
.
get
(
index
-
1
);
mLibVLC
.
readMedia
(
mCurrentMedia
.
getPath
());
showNotification
();
}
else
return
;
mLibVLC
.
readMedia
(
mCurrentMedia
.
getPath
());
showNotification
();
}
private
void
shuffle
()
{
if
(
mShuffling
)
mPlayedMedia
.
clear
();
mShuffling
=
!
mShuffling
;
}
private
void
repeat
()
{
mRepeating
=
!
mRepeating
;
}
private
IAudioService
.
Stub
mInterface
=
new
IAudioService
.
Stub
()
{
...
...
@@ -197,6 +226,16 @@ public class AudioService extends Service {
return
mLibVLC
.
isPlaying
();
}
@Override
public
boolean
isShuffling
()
{
return
mShuffling
;
}
@Override
public
boolean
isRepeating
()
{
return
mRepeating
;
}
@Override
public
boolean
hasMedia
()
throws
RemoteException
{
return
mMediaList
.
size
()
!=
0
;
...
...
@@ -257,7 +296,8 @@ public class AudioService extends Service {
throws
RemoteException
{
mEventManager
.
addHandler
(
mEventHandler
);
mMediaList
.
clear
();
mPlayedMedia
.
clear
();
mPrevious
.
clear
();
DatabaseManager
db
=
DatabaseManager
.
getInstance
();
for
(
int
i
=
0
;
i
<
mediaPathList
.
size
();
i
++)
{
String
path
=
mediaPathList
.
get
(
i
);
...
...
@@ -285,6 +325,15 @@ public class AudioService extends Service {
AudioService
.
this
.
previous
();
}
public
void
shuffle
()
throws
RemoteException
{
AudioService
.
this
.
shuffle
();
}
@Override
public
void
repeat
()
throws
RemoteException
{
AudioService
.
this
.
repeat
();
}
@Override
public
void
setTime
(
long
time
)
throws
RemoteException
{
mLibVLC
.
setTime
(
time
);
...
...
@@ -292,8 +341,11 @@ public class AudioService extends Service {
@Override
public
boolean
hasNext
()
throws
RemoteException
{
if
(
mRepeating
)
return
false
;
int
index
=
mMediaList
.
indexOf
(
mCurrentMedia
);
if
(
index
<
mMediaList
.
size
()
-
1
)
if
(
mShuffling
&&
mPlayedMedia
.
size
()
<
mMediaList
.
size
()
||
index
<
mMediaList
.
size
()
-
1
)
return
true
;
else
return
false
;
...
...
@@ -301,8 +353,10 @@ public class AudioService extends Service {
@Override
public
boolean
hasPrevious
()
throws
RemoteException
{
if
(
mRepeating
)
return
false
;
int
index
=
mMediaList
.
indexOf
(
mCurrentMedia
);
if
(
index
>
0
)
if
(
mPrevious
.
size
()
>
0
||
index
>
0
)
return
true
;
else
return
false
;
...
...
vlc-android/src/org/videolan/vlc/android/AudioServiceController.java
View file @
ae0047a9
...
...
@@ -301,4 +301,41 @@ public class AudioServiceController implements AudioPlayerControl {
return
false
;
}
@Override
public
void
shuffle
()
{
try
{
mAudioServiceBinder
.
shuffle
();
}
catch
(
RemoteException
e
)
{
Log
.
e
(
TAG
,
"remote procedure call failed: shuffle()"
);
}
}
@Override
public
void
repeat
()
{
try
{
mAudioServiceBinder
.
repeat
();
}
catch
(
RemoteException
e
)
{
Log
.
e
(
TAG
,
"remote procedure call failed: repeat()"
);
}
}
@Override
public
boolean
isShuffling
()
{
try
{
return
mAudioServiceBinder
.
isShuffling
();
}
catch
(
RemoteException
e
)
{
Log
.
e
(
TAG
,
"remote procedure call failed: isShuffling()"
);
return
false
;
}
}
@Override
public
boolean
isRepeating
()
{
try
{
return
mAudioServiceBinder
.
isRepeating
();
}
catch
(
RemoteException
e
)
{
Log
.
e
(
TAG
,
"remote procedure call failed: isRepeating()"
);
return
false
;
}
}
}
vlc-android/src/org/videolan/vlc/android/IAudioService.aidl
View file @
ae0047a9
...
...
@@ -7,10 +7,14 @@ interface IAudioService {
void
stop
();
void
next
();
void
previous
();
void
shuffle
();
void
repeat
();
void
setTime
(
long
time
);
String
getCurrentMediaPath
();
void
load
(
in
List
<
String
>
mediaPathList
,
int
position
);
boolean
isPlaying
();
boolean
isShuffling
();
boolean
isRepeating
();
boolean
hasMedia
();
boolean
hasNext
();
boolean
hasPrevious
();
...
...
Write
Preview
Markdown
is supported
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