diff --git a/io/How to Add Custom File Attributes/src/main/java/com/javacreed/examples/io/Example.java b/io/How to Add Custom File Attributes/src/main/java/com/javacreed/examples/io/Example.java
index a098836..6941219 100644
--- a/io/How to Add Custom File Attributes/src/main/java/com/javacreed/examples/io/Example.java
+++ b/io/How to Add Custom File Attributes/src/main/java/com/javacreed/examples/io/Example.java
@@ -1,15 +1,15 @@
package com.javacreed.examples.io;
-import java.io.File;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.attribute.UserDefinedFileAttributeView;
public class Example {
public static void main(final String[] args) throws Exception {
- final Path file = new File(Example.class.getResource("/samples/example.txt").toURI()).getAbsoluteFile().toPath();
+ final Path file = Paths.get(Example.class.getResource("/samples/example.txt").toURI()).toAbsolutePath();
final UserDefinedFileAttributeView view = Files.getFileAttributeView(file, UserDefinedFileAttributeView.class);
diff --git a/io/How to Read File Attributes/pom.xml b/io/How to Read File Attributes/pom.xml
index a014a61..a685b7f 100644
--- a/io/How to Read File Attributes/pom.xml
+++ b/io/How to Read File Attributes/pom.xml
@@ -95,4 +95,13 @@
+
+
+
+ uk.co.caprica
+ vlcj
+ 3.1.0
+
+
+
\ No newline at end of file
diff --git a/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example.java b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example.java
new file mode 100644
index 0000000..f07053f
--- /dev/null
+++ b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example.java
@@ -0,0 +1,27 @@
+package com.javacreed.examples.io;
+
+import java.util.concurrent.TimeUnit;
+
+import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
+import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
+import uk.co.caprica.vlcj.runtime.RuntimeUtil;
+
+import com.sun.jna.NativeLibrary;
+
+public class Example {
+
+ public static void main(final String[] args) throws Exception {
+
+ final String vlcLibPath = "C:\\Users\\Mona Lisa\\Downloads\\vlc-2.1.5";
+ final String mediaPath = "\\\\192.168.75.25\\Data\\sd\\videos\\England\\2014_2015\\Premier_League\\Arsenal_vs._Aston_Villa\\908093_0\\Arsenal_vs._Aston_Villa.mp4";
+
+ NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcLibPath);
+ final EmbeddedMediaPlayerComponent embeddedMediaPlayerComponent = new EmbeddedMediaPlayerComponent();
+ EmbeddedMediaPlayer embeddedMediaPlayer = embeddedMediaPlayerComponent.getMediaPlayer();
+ embeddedMediaPlayer.prepareMedia(mediaPath);
+ embeddedMediaPlayer.parseMedia();
+
+ System.out.println("Length: " + embeddedMediaPlayer.getLength());
+ System.out.println("Dimentions: " + embeddedMediaPlayer.getVideoDimension());
+ }
+}
diff --git a/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example2.java b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example2.java
new file mode 100644
index 0000000..d8257f1
--- /dev/null
+++ b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example2.java
@@ -0,0 +1,51 @@
+package com.javacreed.examples.io;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
+import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
+import uk.co.caprica.vlcj.runtime.RuntimeUtil;
+
+import com.sun.jna.NativeLibrary;
+
+public class Example2 {
+
+ public static void main(final String[] args) throws Exception {
+
+ final String vlcLibPath = "C:\\Users\\Mona Lisa\\Downloads\\vlc-2.1.5";
+ final String mediaPath = "\\\\192.168.75.25\\Data\\sd\\videos\\England\\2014_2015\\Premier_League\\Arsenal_vs._Aston_Villa\\908093_0\\Arsenal_vs._Aston_Villa.mp4";
+
+ NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcLibPath);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final JFrame frame = new JFrame("Playing Video with VLC (Part 1)");
+ final EmbeddedMediaPlayerComponent embeddedMediaPlayerComponent = new EmbeddedMediaPlayerComponent();
+ frame.setContentPane(embeddedMediaPlayerComponent);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(1200, 800);
+ frame.setVisible(true);
+
+ final EmbeddedMediaPlayer mediaPlayer = embeddedMediaPlayerComponent.getMediaPlayer();
+ mediaPlayer.playMedia(mediaPath);
+
+ System.out.println("Length: " + mediaPlayer.getLength());
+ System.out.println("Dimentions: " + mediaPlayer.getVideoDimension());
+
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ try {
+ mediaPlayer.release();
+ } catch (Exception ex) {/* Ignore */}
+ }
+ });
+ }
+ });
+ }
+}
diff --git a/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example3.java b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example3.java
new file mode 100644
index 0000000..b333e33
--- /dev/null
+++ b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example3.java
@@ -0,0 +1,16 @@
+package com.javacreed.examples.io;
+
+
+public class Example3 {
+
+
+ public static void main(String[] args) throws Exception {
+
+
+
+ System.load("C:\\Windows\\System32\\Shell32.dll");
+
+
+ System.out.println("Done");
+ }
+}
diff --git a/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example4.java b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example4.java
new file mode 100644
index 0000000..fc744b3
--- /dev/null
+++ b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example4.java
@@ -0,0 +1,59 @@
+package com.javacreed.examples.io;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
+import uk.co.caprica.vlcj.player.MediaPlayer;
+import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;
+import uk.co.caprica.vlcj.player.MediaPlayerEventListener;
+import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
+import uk.co.caprica.vlcj.runtime.RuntimeUtil;
+
+import com.sun.jna.NativeLibrary;
+
+public class Example4 {
+
+ public static void main(final String[] args) throws Exception {
+
+ final String vlcLibPath = "C:\\Users\\Mona Lisa\\Downloads\\vlc-2.1.5";
+ // final String mediaPath = "\\\\192.168.75.25\\Data\\sd\\videos\\England\\2014_2015\\Premier_League\\Arsenal_vs._Aston_Villa\\908093_0\\Arsenal_vs._Aston_Villa.mp4";
+ final String mediaPath = "\\\\192.168.75.25\\Data\\sd\\videos\\Argentina\\2014\\Primera_A\\Arsenal_de_Sarandí_vs._Banfield\\937560_0\\Arsenal_de_Sarandí_vs._Banfield.mp4";
+ NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcLibPath);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final EmbeddedMediaPlayerComponent embeddedMediaPlayerComponent = new EmbeddedMediaPlayerComponent();
+
+ final JFrame application = new JFrame("Test");
+ application.setContentPane(embeddedMediaPlayerComponent);
+ application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ application.setExtendedState(Frame.MAXIMIZED_BOTH);
+ application.setVisible(true);
+
+ final EmbeddedMediaPlayer embeddedMediaPlayer = embeddedMediaPlayerComponent.getMediaPlayer();
+ embeddedMediaPlayer.playMedia(mediaPath);
+
+ final MediaPlayerEventListener listener = new MediaPlayerEventAdapter() {
+ @Override
+ public void positionChanged(final MediaPlayer mediaPlayer, final float newPosition) {
+ final Dimension dimension = mediaPlayer.getVideoDimension();
+ if (dimension != null) {
+ System.out.printf("%d X %d%n", dimension.width, dimension.height);
+ embeddedMediaPlayer.removeMediaPlayerEventListener(this);
+ application.setVisible(false);
+ application.dispose();
+ }
+ }
+ };
+
+ embeddedMediaPlayer.addMediaPlayerEventListener(listener);
+ }
+ });
+
+ }
+}
diff --git a/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example5.java b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example5.java
new file mode 100644
index 0000000..fb5140f
--- /dev/null
+++ b/io/How to Read File Attributes/src/main/java/com/javacreed/examples/io/Example5.java
@@ -0,0 +1,168 @@
+package com.javacreed.examples.io;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class Example5 {
+
+ private static class MediaInfo {
+
+ public static MediaInfo parse(final String data) {
+
+ final MediaInfo mediaInfo = new MediaInfo();
+
+ Section section = null;
+
+ for (final String line : data.split("(\\r\\n|\\r|\\n)")) {
+ if (line.isEmpty()) {
+ section = null;
+ continue;
+ }
+
+ if (section == null) {
+ section = mediaInfo.addSection(Section.parse(line));
+ continue;
+ }
+
+ section.add(NameValue.parse(line));
+ }
+
+ return mediaInfo;
+ }
+
+ private final Map sections = new LinkedHashMap<>();
+
+ public Section addSection(final Section section) {
+ final String name = section.getName();
+ if (sections.containsKey(name)) {
+ throw new IllegalArgumentException("Duplicate section name: '" + name + "'");
+ }
+
+ sections.put(name, section);
+ return section;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder formatted = new StringBuilder();
+ if (sections.isEmpty()) {
+ formatted.append("No information found!!!");
+ } else {
+ for (final Section section : sections.values()) {
+ formatted.append(section);
+ }
+ }
+
+ return formatted.toString();
+ }
+ }
+
+ public static class NameValue {
+ public static NameValue parse(final String line) {
+ final String[] parts = line.split(":", 2);
+ return new NameValue(parts[0].trim(), parts[1].trim());
+ }
+
+ private final String name;
+ private final String value;
+
+ public NameValue(final String name, final String value) {
+ this.name = Objects.requireNonNull(name);
+ this.value = Objects.requireNonNull(value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[%s] = '%s'", name, value);
+ }
+
+ }
+
+ private static class Section {
+ public static Section parse(final String line) {
+ if (line.contains(":")) {
+ throw new IllegalArgumentException("Section name should not have ':'");
+ }
+
+ return new Section(line.trim());
+ }
+
+ private final String name;
+
+ private final Map values = new LinkedHashMap<>();
+
+ public Section(final String name) {
+ this.name = Objects.requireNonNull(name);
+ }
+
+ public void add(final NameValue nameValue) {
+ final String name = nameValue.getName();
+ if (values.containsKey(name)) {
+ throw new IllegalArgumentException("Duplicate name: '" + name + "'");
+ }
+
+ values.put(name, nameValue);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder formatted = new StringBuilder();
+ formatted.append(name).append("\n");
+ if (values.isEmpty()) {
+ formatted.append(" No values!!!\n");
+ } else {
+ for (final NameValue nameValue : values.values()) {
+ formatted.append(" ").append(nameValue).append("\n");
+ }
+ }
+ return formatted.toString();
+ }
+ }
+
+ private static String executeMediaInfo(final String mediaPath) throws IOException, InterruptedException {
+ final String exePath = "C:\\Users\\Mona Lisa\\Downloads\\MediaInfo_CLI_0.7.72_Windows_x64\\MediaInfo.exe";
+ final ProcessBuilder builder = new ProcessBuilder(exePath, mediaPath);
+ builder.redirectErrorStream();
+ final Process process = builder.start();
+
+ final StringBuilder buffer = new StringBuilder();
+ try (Reader reader = new InputStreamReader(process.getInputStream())) {
+ for (int i; (i = reader.read()) != -1;) {
+ buffer.append((char) i);
+ }
+ }
+
+ final int status = process.waitFor();
+ if (status == 0) {
+ return buffer.toString();
+ }
+
+ throw new IOException("Unexpected exit status " + status);
+ }
+
+ public static void main(final String[] args) throws Exception {
+
+ final String mediaPath = "\\\\192.168.75.25\\Data\\sd\\videos\\Argentina\\2014\\Primera_A\\Arsenal_de_Sarandí_vs._Banfield\\937560_0\\Arsenal_de_Sarandí_vs._Banfield.mp4";
+
+ final String data = Example5.executeMediaInfo(mediaPath);
+ final MediaInfo mediaInfo = MediaInfo.parse(data);
+ System.out.println(mediaInfo);
+ System.out.println("Done");
+ }
+}