<string name="empty_generic_secondary">To copy music from your computer to your device, use a USB cable.</string>
<string name="empty_queue_main">No songs in play queue</string>
<string name="empty_queue_secondary">To add songs to your Play Queue, tap the options menu on a song, album, or artist and select \"Add to queue\".</string>
- <string name="error_playing_track">Unable to play track %1$s, removing it from the queue</string>
+ <string name="error_playing_track">Unable to play track %1$s</string>
<!-- Section Headers -->
<string name="header_unknown_year">Unknown year</string>
}
stop(false);
+ boolean shutdown = false;
+
updateCursor(mPlaylist.get(mPlayPos).mId);
while (true) {
if (mCursor != null
+ mCursor.getLong(IDCOLIDX))) {
break;
}
+
// if we get here then opening the file failed. We can close the
// cursor now, because
// we're either going to create a new one next, or stop trying
if (mOpenFailedCounter++ < 10 && mPlaylist.size() > 1) {
final int pos = getNextPosition(false);
if (pos < 0) {
- scheduleDelayedShutdown();
- if (mIsSupposedToBePlaying) {
- mIsSupposedToBePlaying = false;
- notifyChange(PLAYSTATE_CHANGED);
- }
- return;
+ shutdown = true;
+ break;
}
mPlayPos = pos;
stop(false);
} else {
mOpenFailedCounter = 0;
Log.w(TAG, "Failed to open file for playback");
- scheduleDelayedShutdown();
- if (mIsSupposedToBePlaying) {
- mIsSupposedToBePlaying = false;
- notifyChange(PLAYSTATE_CHANGED);
- }
- return;
+ shutdown = true;
+ break;
}
}
- if (openNext) {
+
+ if (shutdown) {
+ scheduleDelayedShutdown();
+ if (mIsSupposedToBePlaying) {
+ mIsSupposedToBePlaying = false;
+ notifyChange(PLAYSTATE_CHANGED);
+ }
+ } else if (openNext) {
setNextTrack();
}
}
}
+ private void sendErrorMessage(final String trackName) {
+ final Intent i = new Intent(TRACK_ERROR);
+ i.putExtra(TrackErrorExtra.TRACK_NAME, trackName);
+ sendBroadcast(i);
+ }
+
/**
* @param force True to force the player onto the track next, false
* otherwise.
mOpenFailedCounter = 0;
return true;
}
+
+ String trackName = getTrackName();
+ if (TextUtils.isEmpty(trackName)) {
+ trackName = path;
+ }
+ sendErrorMessage(trackName);
+
stop(true);
return false;
}
*/
public String getGenreName() {
synchronized (this) {
- if (mCursor == null) {
+ if (mCursor == null || mPlayPos < 0 || mPlayPos >= mPlaylist.size()) {
return null;
}
String[] genreProjection = { MediaStore.Audio.Genres.NAME };
break;
case SERVER_DIED:
if (service.isPlaying()) {
- final Intent i = new Intent(TRACK_ERROR);
final TrackErrorInfo info = (TrackErrorInfo)msg.obj;
- i.putExtra(TrackErrorExtra.TRACK_NAME, info.mTrackName);
- service.sendBroadcast(i);
+ service.sendErrorMessage(info.mTrackName);
// since the service isPlaying(), we only need to remove the offending
// audio track, and the code will automatically play the next track