use of com.amaze.filemanager.utils.SmbStreamer.Streamer in project AmazeFileManager by TeamAmaze.
the class MainFragment method launchSMB.
public static void launchSMB(final SmbFile smbFile, final long si, 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(smbFile, si);
activity.runOnUiThread(() -> {
try {
Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath())).getEncodedPath());
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, MimeTypes.getMimeType(smbFile.getPath(), smbFile.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 | SmbException e) {
e.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
Aggregations