Properly fix #5 (missing import), formatting.

This commit is contained in:
Felix Ableitner 2014-05-04 17:49:11 +02:00
parent 9bc05b12f5
commit 59df28b2bd

View file

@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.github.nutomic.controldlna.upnp; package com.github.nutomic.controldlna.upnp;
import java.lang.NumberFormatException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
@ -380,20 +381,17 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0); Message msg = Message.obtain(null, Provider.MSG_STATUS_INFO, 0, 0);
Builder status = null; Builder status = null;
status = new MediaItemStatus.Builder(mPlaybackState);
if (positionInfo.getTrackURI() != null && positionInfo.getTrackURI().equals(itemId)) { if (positionInfo.getTrackURI() != null && positionInfo.getTrackURI().equals(itemId)) {
try { try {
status = new MediaItemStatus.Builder(mPlaybackState) status.setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000)
.setContentPosition(positionInfo.getTrackElapsedSeconds() * 1000)
.setContentDuration(positionInfo.getTrackDurationSeconds() * 1000) .setContentDuration(positionInfo.getTrackDurationSeconds() * 1000)
.setTimestamp(positionInfo.getAbsCount()); .setTimestamp(positionInfo.getAbsCount());
} }
catch (NumberFormatException e) { catch (NumberFormatException e) {
status = new MediaItemStatus.Builder(mPlaybackState);
Log.d(TAG, "Failed to read track position or duration", e); Log.d(TAG, "Failed to read track position or duration", e);
} }
} }
else
status = new MediaItemStatus.Builder(mPlaybackState);
msg.getData().putBundle("media_item_status", status.build().asBundle()); msg.getData().putBundle("media_item_status", status.build().asBundle());
msg.getData().putInt("hash", requestHash); msg.getData().putInt("hash", requestHash);