MCPcopy Index your code
hub / github.com/OpenSourcePhysics/osp / createVideoLabel

Method createVideoLabel

src/test/Test_Video.java:192–250  ·  view source on GitHub ↗
(File file, URL videoURL, String video)

Source from the content-addressed store, hash-verified

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

Callers 2

Test_VideoMethod · 0.95
loadVideoMethod · 0.95

Calls 9

getMP4CodecMethod · 0.95
addActionListenerMethod · 0.95
readAllBytesMethod · 0.80
setIconMethod · 0.80
equalsMethod · 0.65
printlnMethod · 0.65
getNameMethod · 0.65
toStringMethod · 0.45
getAbsolutePathMethod · 0.45

Tested by

no test coverage detected