Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Pause/resume media overlay #74

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public byte[] handle(byte[] data, String mime, String uriPath,

private boolean mIsMoAvailable;
private boolean mIsMoPlaying;
private boolean mShouldResumeMO;
private int mEpubRsoInjectCounter = 0;

@Override
Expand Down Expand Up @@ -287,6 +288,12 @@ protected void onDestroy() {
@Override
protected void onPause() {
super.onPause();

if (mIsMoPlaying) {
mShouldResumeMO = true;
mReadiumJSApi.pauseMediaOverlay();
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mWebview.onPause();
}
Expand All @@ -295,6 +302,12 @@ protected void onPause() {
@Override
protected void onResume() {
super.onResume();

if (mShouldResumeMO) {
mShouldResumeMO = false;
mReadiumJSApi.playMediaOverlay();
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mWebview.onResume();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ public void toggleMediaOverlay(){
loadJSOnReady("ReadiumSDK.reader.toggleMediaOverlay();");
}

public void pauseMediaOverlay(){
loadJSOnReady("ReadiumSDK.reader.pauseMediaOverlay();");
}

public void playMediaOverlay(){
loadJSOnReady("ReadiumSDK.reader.playMediaOverlay();");
}



private void loadJSOnReady(String jScript) {
Expand Down