Open ntanvinh opened 3 years ago
Same problem, location not streaming.
I just created a pr for getting the page number for iOS but it seems no stream is ever emitted for android. This is the link to my pr: https://github.com/JideGuru/epub_viewer/pull/103
Locator stream still seems to be an issue. Is this repo being maintained, i ended up using this, and resuming the last read page seems to be a problem for books (android). :(
yeh I cant get this to work either, it does print the locator stream when you cclose the book, but how to pass it in so we can resume reading?
Locator Stream is working. Save the fromJson response to a variable and then access the details. final readLocator = EpubLocator.fromJson(jsonDecode(locator)); print(readLocator.href);
I am using the latest version ^0.2.4.
@pranjalpc99 your call is going into the listening part? See here is my code if you get any error into this please let me know
if (await file.exists()) {
EpubViewer.setConfig(
themeColor: Color(0xFFA1687C),
identifier: 'iosBook',
scrollDirection: EpubScrollDirection.ALLDIRECTIONS,
allowSharing: true,
enableTts: true,
);
EpubViewer.open(file.path);
EpubViewer.locatorStream.listen((locator) {
print('LOCATOR: ${EpubLocator.fromJson(jsonDecode(locator))}');
});
}
Here I am not getting that log for LOCATOR
final readLocator = EpubLocator.fromJson(jsonDecode(locator)); print(readLocator.href);
how can use it pls send if you want
@pranjalpc99 your call is going into the listening part? See here is my code if you get any error into this please let me know
if (await file.exists()) { EpubViewer.setConfig( themeColor: Color(0xFFA1687C), identifier: 'iosBook', scrollDirection: EpubScrollDirection.ALLDIRECTIONS, allowSharing: true, enableTts: true, ); EpubViewer.open(file.path); EpubViewer.locatorStream.listen((locator) { print('LOCATOR: ${EpubLocator.fromJson(jsonDecode(locator))}'); }); }
Here I am not getting that log for LOCATOR
Okay, So what I have done is that I have written the code to listen to the broadcast receiver in the build method inside the try-catch block. Then whenever EpubViewer is called your application will go in the paused state and when you close the EpubViewer the last route will go in resume state and the build method will be called again.
This might be a hack but for me it works.
@pranjalpc99 you might be using openAsset
method. I am using only the open
method.
and I have resolved that issue by done changes to the open
method itself...
@mustafaMtfa I am also using the open method only. Can you share the changes you did to the open method to resolve the issue?
sure!
_channel.invokeMethod('setChannel');
and I have also started the stream before we are open the book like this.
EpubViewer.setConfig(
themeColor: Color(0xFFA1687C),
identifier: 'iosBook',
scrollDirection: EpubScrollDirection.ALLDIRECTIONS,
allowSharing: true,
enableTts: true,
);
EpubViewer.locatorStream.listen((locator) {
print('LOCATOR: ${EpubLocator.fromJson(jsonDecode(locator)).toJson()}');
});
EpubViewer.open(file.path);
@mustafaMtfa what is the purpose of using _channel.invokeMethod('setChannel');
I didn't understand that part. Also, are you able to listen to the stream every time if you start the stream before opening the book. Because I tried and it used to listen only a few times
Actually _channel.invokeMethod('setChannel');
invokes a native method in android or iOS and it starts the listener in native code which returns a stream to locatorStream
Ohh Ok. Nice to know that.
Issue / Feature - Locator of epub file Platform (android, iOS or both) - android Crash / Error - Not work as expected
Steps to reproduce / Describe in detail - I'm copy code from example. However, this code to get locator has never been run.
When I pressed back button, the console still show the readLocator but nothing show from the print statement:
I/readLocator(29636): -> saveReadLocator -> {"bookId":"978-1-5457-4803-9","href":"/OEBPS/html/Preface.xhtml","created":1616838857610,"locations":{"cfi":"epubcfi(/0!/4/16/5:0)"},"title":""}
Please fix it or maybe I have to do something else? I'm using the latest version of the package 0.1.9.