From 6960fc0c18a10d009bc760c5500cc8fc59f4f2aa Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 4 May 2014 13:04:52 +0200 Subject: [PATCH] Fixes #5 --- .../upnp/RemotePlayServiceBinder.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/github/nutomic/controldlna/upnp/RemotePlayServiceBinder.java b/src/com/github/nutomic/controldlna/upnp/RemotePlayServiceBinder.java index 1c33eac..0a63498 100644 --- a/src/com/github/nutomic/controldlna/upnp/RemotePlayServiceBinder.java +++ b/src/com/github/nutomic/controldlna/upnp/RemotePlayServiceBinder.java @@ -380,11 +380,18 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub { Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0); Builder status = null; - if (positionInfo.getTrackURI() != null && positionInfo.getTrackURI().equals(itemId)) - status = new MediaItemStatus.Builder(mPlaybackState) - .setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000) - .setContentDuration(positionInfo.getTrackDurationSeconds() * 1000) - .setTimestamp(positionInfo.getAbsCount()); + if (positionInfo.getTrackURI() != null && positionInfo.getTrackURI().equals(itemId)) { + try { + status = new MediaItemStatus.Builder(mPlaybackState) + .setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000) + .setContentDuration(positionInfo.getTrackDurationSeconds() * 1000) + .setTimestamp(positionInfo.getAbsCount()); + } + catch (NumberFormatException e) { + status = new MediaItemStatus.Builder(mPlaybackState); + Log.d(TAG, "Failed to read track position or duration", e); + } + } else status = new MediaItemStatus.Builder(mPlaybackState);