I want to stream an URL in the MX video player and in VLC. When the URL ends with comx, the MX Video Player handles the work well but when it ends with covlc, it gives me an error. The error is:
cannot find symbol method startActivityForResult(Intent,int)
Here is the class:
public class MyAppWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String str=new String(url);
if(str.endsWith("comx")){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
Uri videoUri = Uri.parse(url.replace("?comx", ""));
intent.setClassName("com.mxtech.videoplayer.ad","com.mxtech.videoplayer.ad.ActivityScreen");
intent.setDataAndType(videoUri, "application/x-mpegURL");
intent.putExtra("secure_uri", true);
intent.putExtra("title", "Kung Fury");
intent.setPackage("com.mxtech.videoplayer.ad");
view.getContext().startActivity(intent);
//view.goBack();
return true;
}
else {
if(str.endsWith("covlc")){
Uri uri = Uri.parse(url.replace("?covlc", ""));
int vlcRequestCode = 42;
Intent vlcIntent = new Intent(Intent.ACTION_VIEW);
vlcIntent.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));
vlcIntent.setDataAndType(uri, "video/*");
vlcIntent.putExtra("title", "Kung Fury");
vlcIntent.putExtra("from_start", false);
vlcIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt");
view.getContext().startActivityForResult(vlcIntent, vlcRequestCode);
return true;
}
else {
//Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
//view.getContext().startActivity(intent);
return false;
}
}
}
}