aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-17 14:34:14 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-17 14:34:14 -0800
commit84f5d4e914de23e82d3da5e7b4ddc1ba8d5bc6b5 (patch)
tree02b96d4020de1615241bd335f284f169187401a7 /src/github
parent15810147ac672f1c08c62672cb01fc4335a78052 (diff)
downloaddsub-84f5d4e914de23e82d3da5e7b4ddc1ba8d5bc6b5.tar.gz
dsub-84f5d4e914de23e82d3da5e7b4ddc1ba8d5bc6b5.tar.bz2
dsub-84f5d4e914de23e82d3da5e7b4ddc1ba8d5bc6b5.zip
Fix casting when transcoded content type is null
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java
index 982b7953..c25805c2 100644
--- a/src/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/src/github/daneren2005/dsub/service/ChromeCastController.java
@@ -223,9 +223,19 @@ public class ChromeCastController extends RemoteController {
meta.addImage(new WebImage(Uri.parse(coverArt)));
}
+ String contentType;
+ if(song.isVideo()) {
+ contentType = "application/x-mpegURL";
+ }
+ else if(song.getTranscodedContentType() != null) {
+ contentType = song.getTranscodedContentType();
+ } else {
+ contentType = song.getContentType();
+ }
+
// Load it into a MediaInfo wrapper
MediaInfo mediaInfo = new MediaInfo.Builder(url)
- .setContentType(song.isVideo() ? "application/x-mpegURL" : song.getTranscodedContentType())
+ .setContentType(contentType)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setMetadata(meta)
.build();
@@ -241,19 +251,25 @@ public class ChromeCastController extends RemoteController {
}
} else if(result.getStatus().getStatusCode() != ConnectionResult.SIGN_IN_REQUIRED) {
Log.e(TAG, "Failed to load: " + result.getStatus().toString());
- downloadService.setPlayerState(PlayerState.STOPPED);
- error = true;
- Util.toast(downloadService, downloadService.getResources().getString(R.string.download_failed_to_load));
+ failedLoad();
}
}
});
} catch (IllegalStateException e) {
Log.e(TAG, "Problem occurred with media during loading", e);
+ failedLoad();
} catch (Exception e) {
Log.e(TAG, "Problem opening media during loading", e);
+ failedLoad();
}
}
+ private void failedLoad() {
+ Util.toast(downloadService, downloadService.getResources().getString(R.string.download_failed_to_load));
+ downloadService.setPlayerState(PlayerState.STOPPED);
+ error = true;
+ }
+
private class ConnectionCallbacks implements GoogleApiClient.ConnectionCallbacks {
@Override