Skip to content

Commit

Permalink
fix cast not working
Browse files Browse the repository at this point in the history
  • Loading branch information
naman14 committed Feb 9, 2019
1 parent cd04e35 commit 987653f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/com/naman14/timberx/cast/CastServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class CastServer(private val context: Context) : NanoHTTPD(CAST_SERVER_PORT) {
} catch (e: FileNotFoundException) {
Timber.e(e, "Failed to read album art from $albumArtUri")
return errorResponse(e.message)
} finally {
fisAlbumArt.closeQuietly()
}
return newChunkedResponse(OK, MIME_TYPE_IMAGE, fisAlbumArt)
} else if (uri?.contains(PART_SONG) == true) {
Expand All @@ -76,8 +74,6 @@ class CastServer(private val context: Context) : NanoHTTPD(CAST_SERVER_PORT) {
} catch (e: FileNotFoundException) {
Timber.e(e, "Failed to read song from $songUri")
return errorResponse(e.message)
} finally {
fisSong.closeQuietly()

This comment has been minimized.

Copy link
@afollestad

afollestad Feb 9, 2019

Collaborator

These are important for memory management

}
return newFixedLengthResponse(OK, MIME_TYPE_AUDIO, fisSong, song.length())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ class MainViewModel(
val castContext = CastContext.getSharedInstance(context.applicationContext)
sessionManager = castContext.sessionManager
if (castSession == null) {
sessionManager?.addSessionManagerListener(sessionManagerListener)
castSession = sessionManager?.currentCastSession?.apply {
remoteMediaClient?.registerCallback(castCallback)
remoteMediaClient?.addProgressListener(castProgressListener, 100)
castSession = sessionManager?.currentCastSession.also {
it?.remoteMediaClient?.registerCallback(castCallback)
it?.remoteMediaClient?.addProgressListener(castProgressListener, 100)
}
sessionManager?.addSessionManagerListener(sessionManagerListener)
} else {
sessionManager?.currentCastSession?.let { castSession = it }
}
Expand Down

0 comments on commit 987653f

Please sign in to comment.