Does anyone know how I can display LIT or EPUB eBook files within Corona, either natively or via a plugin?
I’m working on a new project that requires me to open eBook files, but I don’t want to require the user to leave my app to open another eBook reader. I’d like to keep the eBook display within a window of my app, similar to how webView works.
I’m unaware of any plugins to process these files. We certainly don’t have any internal API’s to process them. EPUB probably has a standardized format. There may be a Lua library out there that can help. I would suggest heading to Google or the search engine of your choice and see what you can find.
You could also post a job request to get a community developer to build a plugin if there are some standard C++/iOS or Android SDK’s that could be incorporated within reason.
But since I don’t know what the format is about, if it’s just text and images, it’s likely possible, but if those formats contain any interactivity, the complexity of such a plugin would be considerably more difficult.
A quick read through that I see couple of hiccups, but I also don’t see things as being horribly impossible.
EPUB is basically HTML and some XML. There is an XML parser in our Business App sample. It’s not perfect, but it will work in many cases. HTML is basically XML, so it should be able to parse an HTML document into a Lua table.
It seems to support several image formats. Corona will support JPEG and PNG. There is a plugin to handle GIF in the marketplace and we have the Nano SVG plugin to attempt to handle the SVG requirements. However the Nano SVG plugin only has limited support for some SVG file.
Where you will run into some potential headaches, is the HTML side. It tends to want to support CSS (and maybe JavaScript) and you can’t do HTML style text with display.newText(). But this is something where you could write the HTML, CSS and any JS files out to your local storage and have a native.newWebView() show the content.
I’m unaware of any plugins to process these files. We certainly don’t have any internal API’s to process them. EPUB probably has a standardized format. There may be a Lua library out there that can help. I would suggest heading to Google or the search engine of your choice and see what you can find.
You could also post a job request to get a community developer to build a plugin if there are some standard C++/iOS or Android SDK’s that could be incorporated within reason.
But since I don’t know what the format is about, if it’s just text and images, it’s likely possible, but if those formats contain any interactivity, the complexity of such a plugin would be considerably more difficult.
A quick read through that I see couple of hiccups, but I also don’t see things as being horribly impossible.
EPUB is basically HTML and some XML. There is an XML parser in our Business App sample. It’s not perfect, but it will work in many cases. HTML is basically XML, so it should be able to parse an HTML document into a Lua table.
It seems to support several image formats. Corona will support JPEG and PNG. There is a plugin to handle GIF in the marketplace and we have the Nano SVG plugin to attempt to handle the SVG requirements. However the Nano SVG plugin only has limited support for some SVG file.
Where you will run into some potential headaches, is the HTML side. It tends to want to support CSS (and maybe JavaScript) and you can’t do HTML style text with display.newText(). But this is something where you could write the HTML, CSS and any JS files out to your local storage and have a native.newWebView() show the content.
local function webListener( event )
if event.url then
print( "You are visiting: " .. event.url )
end
if event.type then
print( "The event.type is " .. event.type ) -- print the type of request
end
if event.errorCode then
native.showAlert( "Error!", event.errorMessage, { "OK" } )
end
end
local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, display.contentHeight )
webView:request( "html/hello.html", system.ResourceDirectory )
webView:addEventListener( "urlRequest", webListener )