Fixed crash if music file has not artist metadata.

This commit is contained in:
Felix Ableitner 2014-01-02 17:25:20 +01:00
parent 0155c3ac67
commit 8d48f73e07
2 changed files with 8 additions and 6 deletions

View file

@ -133,7 +133,8 @@ public class MediaRouterPlayService extends Service {
title = mPlaylist.get(mCurrentTrack).getTitle();
if (mPlaylist.get(mCurrentTrack) instanceof MusicTrack) {
MusicTrack track = (MusicTrack) mPlaylist.get(mCurrentTrack);
artist = track.getArtists()[0].getName();
if (track.getArtists().length > 0)
artist = track.getArtists()[0].getName();
}
}
Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class);

View file

@ -89,6 +89,7 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
DIDLObject item = getItem(position);
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView artist = (TextView) convertView.findViewById(R.id.subtitle);
artist.setText("");
RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.image);
if (item instanceof MusicTrack) {
MusicTrack track = (MusicTrack) item;
@ -96,12 +97,12 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
? Integer.toString(track.getOriginalTrackNumber()) + ". "
: "";
title.setText(trackNumber + item.getTitle());
artist.setText(track.getArtists()[0].getName());
if (track.getArtists().length > 0)
artist.setText(track.getArtists()[0].getName());
}
else {
else
title.setText(item.getTitle());
artist.setText("");
}
image.setImageUri(item.getFirstPropertyValue(
DIDLObject.Property.UPNP.ALBUM_ART_URI.class));
return convertView;