sclass JVideoLibDownloader is Swingable { transient SingleComponentPanel scp; selfType forward(IF0 forward) { this.forward = forward; this; } swappable JComponent forward() { ret jcenteredlabel("Video extensions enabled"); } S libID() { ret ffmpegLibraryIDForPlatform(); } bool videoSupported() { ret libID() != null; } bool libDownloaded() { ret fileExists(DiskSnippetCache_getLibrary(libID())); } bool hasLib() { bool has = currentProgramHasLibrary(DiskSnippetCache_getLibrary(libID())); print("Video library ID: " + libID() + ", loaded: " + has); ret has; } void addLib() { if (videoSupported()) if (addLibraryToCurrentProgram(libID())) print("Video library loaded: " + libID()); } visualize { if (scp == null) scp = singleComponentPanel(makeComponent()); ret scp; } JComponent makeComponent() { if (!videoSupported()) ret jcenteredlabel("Video playback is not yet supported on your platform"); if (libDownloaded()) { addLib(); ret forward(); } else ret jfullcenter(centerAndEastWithMargin( jcenteredlabel("Download video player for " + platformName() + "(ca. 20 MB)?"), jbuttonWithDisable("OK", r addLibWithProgressBar))); } void addLibWithProgressBar { scp.setComponent(jcenteredlabel("Downloading extension...")); try { addLib(); scp.setComponent(forward()); } catch print e { scp.setComponent(jErrorView(e)); } } }