Skip to content

Minimum code to get an epub reader running #54

Answered by mickael-menu
mrifni asked this question in Q&A
Discussion options

You must be logged in to vote

1. Parse an EPUB file into a Publication model using the Streamer

val streamer = Streamer(context)
val epubFile = File(...)
val publication = streamer.open(FileAsset(epubFile))
    .getOrElse { error ->
        val message = error.getUserMessage(context)
    }

2. Add the Publication to the local HTTP server to serve the EPUB content

(We want to remove this step eventually, it depends on https://github.com/readium/r2-testapp-kotlin/issues/297)

// See `R2App` in the test app for an example on how to manage the server.
val s = ServerSocket(0)
s.close()
val server = Server(s.localPort, context)
server.start()

// The base URL will be necessary to create the EPUB navigator
val baseUrl = server…

Replies: 0 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mickael-menu
Comment options

You must be logged in to vote
1 reply
@mickael-menu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants