Hi
I’m having some problems related to large file downloads blocking the UI on
iOS. I’ve created a test case to illustrate the problem.
public void start() {
if(current != null){
current.show();
return;
}
final String url = "https://apps.vchapp.com/LOS%20CLANNERS02.zip";
final String cache = FileSystemStorage.getInstance().getAppHomePath() +
"Video.mp4";
Form hi = new Form("Video Test", new BorderLayout());
Tabs tab = new Tabs();
Button btnDownload = new Button("Download");
Button btnRemove = new Button("Remove");
Container contButtons = new Container(new FlowLayout());
contButtons.add(btnDownload).add(btnRemove);
Container contVideo = new Container(new BorderLayout());
Container contTabVideo = new Container(new BorderLayout());
contTabVideo.add(BorderLayout.CENTER, contVideo)
.add(BorderLayout.SOUTH,
FlowLayout.encloseCenterMiddle(contButtons));
tab.addTab("Video Tab", contTabVideo);
tab.addTab("Test Tab", new Container());
hi.add(BorderLayout.CENTER, tab);
hi.show();
Media[] mVideo = {null};
btnDownload.addActionListener((evt) -> {
contButtons.replace(btnDownload, new InfiniteProgress(), null);
contButtons.revalidate();
/**
* Large file download blocks UI on iOS
*/
Util.downloadUrlToFileSystemInBackground(url, cache, (e) -> {
contButtons.replace(contButtons.getComponentAt(0), btnDownload,
null);
try {
mVideo[0] = MediaManager.createMedia(cache, true);
MediaPlayer mp = new MediaPlayer(mVideo[0]);
mp.setAutoplay(true);
/**
* Loop not working
*/
mp.setLoop(true);
contVideo.add(BorderLayout.CENTER, mp);
contVideo.revalidate();
} catch(IOException io) {
}
});
});
btnRemove.addActionListener((evt) -> {
if (FileSystemStorage.getInstance().exists(cache)) {
FileSystemStorage.getInstance().delete(cache);
if (mVideo[0] != null) {
mVideo[0].cleanup();
contVideo.removeComponent(contVideo.getComponentAt(0));
contVideo.revalidate();
}
ToastBar.showMessage("Video removed", FontImage.MATERIAL_INFO);
}
});
}
In the code above, if you press the button to download a Video, you can see
the UI is blocked until it starts playing. You can’t even switch tabs.
This is happening on a old iPad Mini 1.
Another problem related with the video is that setLoop is not working. I
can workaround this issue but not the blocked UI.
Thanks
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/977f48c3-3bfa-46cc-824b-99063aef1c46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.