Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

63
LINES

< > BotCompany Repo | #1035135 // JVideoLibDownloader backup

JavaX fragment (include)

1  
sclass JVideoLibDownloader is Swingable {
2  
  transient SingleComponentPanel scp;
3  
  
4  
  selfType forward(IF0<JComponent> forward) {
5  
    this.forward = forward;
6  
    this;
7  
  }
8  
  
9  
  swappable JComponent forward() {
10  
    ret jcenteredlabel("Video extensions enabled");
11  
  }
12  
  
13  
  S libID() {
14  
    ret ffmpegLibraryIDForPlatform();
15  
  }
16  
  
17  
  bool videoSupported() { ret libID() != null; }
18  
  
19  
  bool libDownloaded() {
20  
    ret fileExists(DiskSnippetCache_getLibrary(libID()));
21  
  }
22  
  
23  
  bool hasLib() {
24  
    bool has = currentProgramHasLibrary(DiskSnippetCache_getLibrary(libID()));
25  
    print("Video library ID: " + libID() + ", loaded: " + has);
26  
    ret has;
27  
  }
28  
  
29  
  void addLib() {
30  
    if (videoSupported())
31  
      if (addLibraryToCurrentProgram(libID()))
32  
        print("Video library loaded: " + libID());
33  
  }
34  
  
35  
  visualize {
36  
    if (scp == null)
37  
      scp = singleComponentPanel(makeComponent());
38  
    ret scp;
39  
  }
40  
  
41  
  JComponent makeComponent() {
42  
    if (!videoSupported())
43  
      ret jcenteredlabel("Video playback is not yet supported on your platform");
44  
      
45  
    if (libDownloaded()) {
46  
      addLib();
47  
      ret forward();
48  
    } else
49  
      ret jfullcenter(centerAndEastWithMargin(
50  
        jcenteredlabel("Download video player for " + platformName() + "(ca. 20 MB)?"),
51  
        jbuttonWithDisable("OK", r addLibWithProgressBar)));
52  
  }
53  
  
54  
  void addLibWithProgressBar {
55  
    scp.setComponent(jcenteredlabel("Downloading extension..."));
56  
    try {
57  
      addLib();
58  
      scp.setComponent(forward());
59  
    } catch print e {
60  
      scp.setComponent(jErrorView(e));
61  
    }
62  
  }
63  
}

Author comment

Began life as a copy of #1034410

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035135
Snippet name: JVideoLibDownloader backup
Eternal ID of this version: #1035135/1
Text MD5: f6618e30e0816c35af6e7ae3d0363171
Author: stefan
Category: javax / video
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 22:52:29
Source code size: 1622 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 55 / 61
Referenced in: [show references]