solodroid

Web Video Caster

Jul 30th, 2025
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 KB | Source Code | 0 0
  1.         styledPlayerView.findViewById(R.id.btn_cast).setOnClickListener(view -> {
  2.             if (contentLoaded) {
  3.                 String packageName = "com.instantbits.cast.webvideo";
  4.                 android.content.pm.PackageManager pm = getPackageManager();
  5.                 boolean isPackageInstalled;
  6.                 try {
  7.                     pm.getPackageInfo(packageName, 0);
  8.                     isPackageInstalled = true;
  9.                 } catch (android.content.pm.PackageManager.NameNotFoundException e) {
  10.                     isPackageInstalled = false;
  11.                 }
  12.                 if (isPackageInstalled) {
  13.                     Intent shareVideo = new Intent(Intent.ACTION_VIEW);
  14.                     shareVideo.setDataAndType(Uri.parse(video_url), "video/*");
  15.                     shareVideo.setPackage(packageName);
  16.                     shareVideo.putExtra("secure_uri", true);
  17.                     new MaterialAlertDialogBuilder(this)
  18.                             .setTitle(getString(R.string.dialog_title_cast))
  19.                             .setMessage(getString(R.string.ready_cast))
  20.                             .setPositiveButton(getString(R.string.dialog_ok), (dialog, which) -> {
  21.                                 startActivity(shareVideo);
  22.                             })
  23.                             .setNegativeButton(getString(R.string.dialog_cancel), (dialogInterface, i) -> {
  24.                             })
  25.                             .show();
  26.                 } else {
  27.                     new MaterialAlertDialogBuilder(this)
  28.                             .setTitle(getString(R.string.whops))
  29.                             .setMessage(getString(R.string.error_cast))
  30.                             .setPositiveButton(getString(R.string.dialog_ok), (dialog, which) -> {
  31.                                 Intent install = new Intent(Intent.ACTION_VIEW);
  32.                                 String uriString = "https://play.google.com/store/apps/details?id=" + packageName;
  33.                                 install.setData(Uri.parse(uriString));
  34.                                 startActivity(install);
  35.                             })
  36.                             .setNegativeButton(getString(R.string.dialog_cancel), (dialogInterface, i) -> {
  37.                             })
  38.                             .show();
  39.                 }
  40.             } else {
  41.                 Toast.makeText(getApplicationContext(), R.string.please_wait, Toast.LENGTH_SHORT).show();
  42.             }
  43.         });
Advertisement
Add Comment
Please, Sign In to add comment