在我的应用程序中,我想从 url 流式传输视频。视频播放完美。当用户单击该 web 视图时,它重定向到视频的 url 并显示警报对话框“使用完成操作”,用户可以通过单击选项 Internet 下载该视频。我想限制这意味着用户只能观看该视频,但可以不要下载那个。我希望用户使用 android 默认播放器观看该视频。提前致谢。
public class PlayVideo extends Activity {
private String vUrl, vName;
private WebView webView;
Button back, home;
TextView videoName;
Vibrator vibrator;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// For full screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.videoplay);
webView = (WebView) findViewById(R.id.webView01);
back = (Button) findViewById(R.id.bBack);
home = (Button) findViewById(R.id.bHome);
videoName = (TextView) findViewById(R.id.tvVidName);
// for vibration when a button clicked
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// getWindow().setFormat(PixelFormat.TRANSLUCENT);
back.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
vibrator.vibrate(40);
finish();
}
});
vName = getIntent().getStringExtra("videoname");
videoName.setText(vName);
vUrl = getIntent().getStringExtra("vid_url");
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
webView.getSettings().setJavaScriptEnabled(true);
Log.i("fired url", vUrl);
webView.loadUrl(vUrl);
}
}