Created
April 24, 2013 16:57
-
-
Save billy-bacon/5453680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected PlaylistInfo doInBackground(AudioTrack... params) { | |
// pull the track out of the single element array... | |
final AudioTrack audioTrack = params[0]; | |
// get the content and segment index | |
final Content content = audioTrack.getContent(); | |
final int segment = audioTrack.getSegment(); | |
// what kind is this (music or audiobook?) | |
final String kindName = content.getKind().getName(); | |
// build the URI to the playlist | |
final String mediaKey = content.getSegments().get(segment).getMediaKey(); | |
final MediaUri mediaUri = new MediaUri(KindName.fromString(kindName), mediaKey); | |
// build the full URL to the playlist | |
final String playlistUrlString = context.getString(R.string.playlist_base) + mediaUri.getUri(); | |
Log.d(TAG, "get playlist at " + playlistUrlString); | |
// this gets the CONTENTS of the playlist as a string | |
final String playlist = getPlaylist(playlistUrlString); | |
// this finds the key URL for the playlist | |
final String keyUrlString = getKeyUrlFromPlaylist(playlist); | |
Log.d(TAG, "key url from playlist: " + keyUrlString); | |
// this gets the actual key bytes | |
final byte[] keyBytes = getKeyBytes(keyUrlString); | |
// we have to check for an existing session - if one exists, the service will return a non-OK status | |
final ResponseStatus responseStatus; | |
// final String errorMessage; | |
// if(checkPosition){ | |
// final PlaybackPositionMessage request = new PlaybackPositionMessage(); | |
// final PlaybackPosition position = new PlaybackPosition(); | |
// position.setPatronId(patron.getId()); | |
// position.setContentId(content.getId()); | |
// request.setPlaybackPosition(position); | |
// final PlaybackPositionMessage message = positionService.get(request); | |
// responseStatus = message.getResponseStatus(); | |
// if(!responseStatus.equals(ResponseStatus.OK)){ | |
// errorMessage = message.getErrorList().get(0).getText(); | |
// }else { | |
// errorMessage = null; | |
// } | |
// }else { | |
// responseStatus = ResponseStatus.OK; | |
// errorMessage = null; | |
// } | |
// this is our (eventual) return value - but we need to save the playlist and key first | |
final PlaylistInfo playlistInfo = new PlaylistInfo( | |
playlistUrlString, | |
keyUrlString, | |
playlist, | |
keyBytes, | |
ResponseStatus.OK, | |
null, | |
mediaKey | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment