(File file, URL videoURL, String video)
| 190 | |
| 191 | JLabel label = new JLabel((String) null); |
| 192 | private void createVideoLabel(File file, URL videoURL, String video) { |
| 193 | boolean asBytes = (file != null); |
| 194 | ImageIcon icon; |
| 195 | if (!isJS && file != null) { |
| 196 | icon = new ImageIcon("test/video_image.png"); |
| 197 | if (!(file.toString().equals(file.getAbsolutePath()))) { |
| 198 | file = new File("site/swingjs/j2s/" + file.toString()); |
| 199 | } |
| 200 | System.out.println(file.getAbsolutePath()); |
| 201 | System.out.println(getMP4Codec(file.getAbsolutePath(), file.getName())); |
| 202 | return; |
| 203 | } else if (asBytes) { |
| 204 | try { |
| 205 | byte[] bytes; |
| 206 | // if (testRemote) { |
| 207 | // bytes = videoURL.openStream().readAllBytes();// Argh! Java 9! |
| 208 | // } else { |
| 209 | bytes = Files.readAllBytes(file.toPath()); |
| 210 | // } |
| 211 | icon = new ImageIcon(bytes, "jsvideo"); |
| 212 | } catch (IOException e1) { |
| 213 | icon = null; |
| 214 | } |
| 215 | } else if (videoURL != null) { |
| 216 | icon = new ImageIcon(videoURL, "jsvideo"); |
| 217 | } else { |
| 218 | icon = new ImageIcon(video, "jsvideo"); |
| 219 | } |
| 220 | label.setIcon(icon); |
| 221 | jsvideo = (HTML5Video) label.getClientProperty("jsvideo"); |
| 222 | Object info = label.getClientProperty("jsvideoinfo"); |
| 223 | if (info != null) { |
| 224 | System.out.println(info); |
| 225 | } |
| 226 | HTML5Video.addActionListener(jsvideo, new ActionListener() { |
| 227 | |
| 228 | @Override |
| 229 | public void actionPerformed(ActionEvent e) { |
| 230 | String event = e.getActionCommand(); |
| 231 | // Object[] sources = (Object[]) e.getSource(); |
| 232 | // HTML5Video target = (HTML5Video) sources[0]; |
| 233 | // Object jsevent = sources[1]; |
| 234 | System.out.println(event + " " + HTML5Video.getCurrentTime(jsvideo)); |
| 235 | if (cbCapture != null && cbCapture.isSelected() && event.equals("canplaythrough")) { |
| 236 | grabImage(); |
| 237 | } |
| 238 | |
| 239 | } |
| 240 | |
| 241 | }); |
| 242 | |
| 243 | // try { |
| 244 | // jsvideo.play(); |
| 245 | // } catch (Throwable e) { |
| 246 | // System.out.println("couldn't play (yet)" + e); |
| 247 | // } |
| 248 | // |
| 249 |
no test coverage detected