Search in sources :

Example 1 with Streamer

use of com.amaze.filemanager.file_operations.filesystem.smbstreamer.Streamer in project AmazeFileManager by TeamAmaze.

the class MainFragment method launchSMB.

public static void launchSMB(final HybridFileParcelable baseFile, final Activity activity) {
    final Streamer s = Streamer.getInstance();
    new Thread() {

        public void run() {
            try {
                /*
          List<SmbFile> subtitleFiles = new ArrayList<SmbFile>();

          // finding subtitles
          for (Layoutelements layoutelement : LIST_ELEMENTS) {
              SmbFile smbFile = new SmbFile(layoutelement.getDesc());
              if (smbFile.getName().contains(smbFile.getName())) subtitleFiles.add(smbFile);
          }
          */
                s.setStreamSrc(baseFile.getSmbFile(), baseFile.getSize());
                activity.runOnUiThread(() -> {
                    try {
                        Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(baseFile.getPath()).getPath())).getEncodedPath());
                        Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setDataAndType(uri, MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
                        PackageManager packageManager = activity.getPackageManager();
                        List<ResolveInfo> resInfos = packageManager.queryIntentActivities(i, 0);
                        if (resInfos != null && resInfos.size() > 0)
                            activity.startActivity(i);
                        else
                            Toast.makeText(activity, activity.getResources().getString(R.string.smb_launch_error), Toast.LENGTH_SHORT).show();
                    } catch (ActivityNotFoundException e) {
                        e.printStackTrace();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }.start();
}
Also used : Streamer(com.amaze.filemanager.file_operations.filesystem.smbstreamer.Streamer) PackageManager(android.content.pm.PackageManager) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) ArrayList(java.util.ArrayList) List(java.util.List) Uri(android.net.Uri) File(java.io.File) SmbFile(jcifs.smb.SmbFile) HybridFile(com.amaze.filemanager.filesystem.HybridFile) SmbException(jcifs.smb.SmbException) ActivityNotFoundException(android.content.ActivityNotFoundException)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Uri (android.net.Uri)1 Streamer (com.amaze.filemanager.file_operations.filesystem.smbstreamer.Streamer)1 HybridFile (com.amaze.filemanager.filesystem.HybridFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SmbException (jcifs.smb.SmbException)1 SmbFile (jcifs.smb.SmbFile)1