iZstreamer.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package de.nplusc.izc.izstreamer;
  7. import com.sun.jna.Native;
  8. import com.sun.jna.NativeLibrary;
  9. import de.nplusc.izc.tools.IOtools.FileTK;
  10. import de.nplusc.izc.tools.IOtools.ZipFileHandler;
  11. import de.nplusc.izc.tools.IOtools.iZformats.IZpackage;
  12. import de.nplusc.izc.tools.baseTools.Messagers;
  13. import de.nplusc.izc.tools.baseTools.Tools;
  14. import java.io.File;
  15. import java.io.IOException;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18. import java.security.MessageDigest;
  19. import java.util.prefs.Preferences;
  20. import org.apache.commons.io.FileUtils;
  21. import uk.co.caprica.vlcj.binding.LibVlc;
  22. import uk.co.caprica.vlcj.runtime.RuntimeUtil;
  23. /**
  24. *
  25. * @author LH
  26. */
  27. public class iZstreamer
  28. {
  29. public static final int width=600;
  30. public static int height=400;
  31. public static void main(String[] args)
  32. {
  33. if (args.length > 0 && args[0].equals("--mkdist"))
  34. {
  35. Preferences.userRoot().put("Toolkit.enableCoreDebug", true + "");
  36. Preferences.userRoot().put("Toolkit.enableFinerDebug", true + "");
  37. String jpath = new File(Player.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
  38. System.out.println(jpath);
  39. try
  40. {
  41. new File(jpath + File.separator + "portableApp").createNewFile(); //erzeuge markerFile für portableMode des iZpacks
  42. }
  43. catch (IOException ex)
  44. {
  45. ex.printStackTrace();
  46. }
  47. FileTK.writeFile("@echo off\n"
  48. + "set bindir=%~dp0\n"
  49. + "cd %bindir%\n"
  50. + "start javaw -jar -Xmx128M %bindir%\\iZStreamer.jar --appsource #sfxjar#\n"
  51. + "REM DUMMYDUMMYDUMMYDUMMY",//<<<<HACK!
  52. jpath + File.separator + "params.sfx");
  53. new File(jpath + "release.jar").delete();//alte jar ausm weg räumen falls nicht schon geschehen
  54. String apath = jpath + File.separator + "iZstreamerStandalone.jar";
  55. IZpackage.wrapArchive(apath, jpath);
  56. System.out.println("zippern");
  57. System.out.println(apath);
  58. if (args.length == 0)
  59. {
  60. Tools.runCmdStreamable(null, System.out, true, "zip", "-A", apath);//sfxen
  61. }
  62. System.out.println("zipped");
  63. System.exit(0);
  64. //sfx-jar mus unloaded sein damit selfpatch geht
  65. }
  66. else
  67. {
  68. if (args.length > 1)
  69. {
  70. if (args[0].equals("--appsource"))
  71. {
  72. try
  73. {
  74. ZipFileHandler ex;
  75. String bitness = System.getProperty("os.arch");
  76. String v_url = "http://nplusc.de/izstream/iZstream-vlc-" + bitness + "-win.zip";
  77. String v_dlp = new File(Player.class.getProtectionDomain().
  78. getCodeSource().getLocation().getPath()).getParent() + "\\vlc.zip";
  79. String versionurl = "http://nplusc.de/izstream/iZstream-vlc.version";
  80. String v_dlvp = new File(Player.class.getProtectionDomain().
  81. getCodeSource().getLocation().getPath()).getParent() + "\\vlc_new.version";
  82. String v_compareTo = new File(Player.class.getProtectionDomain().
  83. getCodeSource().getLocation().getPath()).getParent() + "\\vlc.version";
  84. FileUtils.copyURLToFile(new URL(versionurl), new File(v_dlvp));
  85. new File(v_compareTo).createNewFile();
  86. Thread.sleep(1000);
  87. System.out.println("v_dlvp"+v_dlvp);
  88. System.out.println("v_compareTo"+v_compareTo);
  89. boolean redl = !FileUtils.contentEquals(new File(v_dlvp), new File(v_compareTo));
  90. if (redl)
  91. {
  92. //checkversion
  93. org.apache.commons.io.FileUtils.copyURLToFile(new URL(v_url), new File(v_dlp));
  94. ex = new ZipFileHandler(v_dlp);
  95. ex.extractAllToDiskWithMonitoringProgressbar(FileTK.getFilePath(v_dlp), null);
  96. ex.unload();
  97. FileUtils.forceDelete(new File(v_compareTo));//SO GEHTS RICHTIG!
  98. FileUtils.copyFile(new File(v_dlvp),new File(v_compareTo));
  99. FileUtils.forceDelete(new File(v_dlp));
  100. FileUtils.forceDelete(new File(v_dlvp));
  101. IZpackage.wrapArchive(args[1], FileTK.getFilePath(v_dlp));//selfmerge
  102. }
  103. else
  104. {
  105. FileUtils.forceDelete(new File(v_dlvp));
  106. }
  107. for (int i = 0; i < 2; i++)
  108. {
  109. try
  110. {
  111. String lpath = FileTK.getFilePath(Player.class.getProtectionDomain().getCodeSource().getLocation().getPath());
  112. System.out.println("lpath" + lpath);
  113. NativeLibrary.addSearchPath(
  114. RuntimeUtil.getLibVlcLibraryName(), lpath);
  115. Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
  116. i = 3;//breakt die schleife bei success
  117. Player.main(null);
  118. return;
  119. }
  120. catch (UnsatisfiedLinkError lickme)//sollte man nicht aber so erkenn ich ob die lib da ist :P
  121. {
  122. lickme.printStackTrace();
  123. if (i == 0)
  124. {
  125. try
  126. {
  127. org.apache.commons.io.FileUtils.copyURLToFile(new URL(v_url), new File(v_dlp));
  128. ex = new ZipFileHandler(v_dlp);
  129. ex.extractAllToDiskWithMonitoringProgressbar(FileTK.getFilePath(v_dlp), null);
  130. ex.unload();
  131. FileUtils.forceDelete(new File(v_dlp));
  132. }
  133. catch (IOException exe)
  134. {
  135. exe.printStackTrace();
  136. }
  137. IZpackage.wrapArchive(args[1], FileTK.getFilePath(v_dlp));
  138. }
  139. else//FUUU
  140. {
  141. Messagers.SingleLineMsg("Fehler beim laden der Komponenten", "Verdammt");
  142. System.exit(0xdeadbeef);
  143. }
  144. }
  145. }
  146. }
  147. catch (MalformedURLException ex)
  148. {
  149. ex.printStackTrace();
  150. }
  151. catch (IOException ex)
  152. {
  153. ex.printStackTrace();
  154. }
  155. catch (InterruptedException ex)
  156. {
  157. ex.printStackTrace();
  158. }
  159. }
  160. }
  161. //System.out.println(Player.class.getProtectionDomain().getCodeSource().getLocation().getPath());
  162. //System.out.println(new File("/D:/src/zu/test/release.jar").length());
  163. //
  164. }
  165. }
  166. }