的Youtube风景模式中的Android
问题描述:
上午通过推出的YouTube播放YouTube的视频文件:的Youtube风景模式中的Android
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(text2.getText().toString()));
intent.setPackage("com.google.android.youtube");
mActivity.startActivity(intent);
有什么办法,我可以restrict user to see videos only in landscape mode
。我dont want to show the comments and relatedvideos
等..
这是可能的。
谢谢
答
不,这是不可能的。您无法控制Youtube应用程序...实际上,您无法确定该应用程序是否会安装。
答
不......你基本上启动外部应用程序来显示该视频,一旦你这样做,你不再有控制。
但是,如果你有视频链接(并非YouTube的链接),你可以尝试显示媒体浏览器和流视频自己:
public class VideoPlayerActivity extends Activity {
private static final String TAG = "VideoPlayerActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
if(getIntent().getExtras() == null || !getIntent().getExtras().containsKey("uri")) {
Log.w(TAG, "URI not found!");
finish();
return;
}
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
final ProgressDialog progressDialog = ProgressDialog.show(this, "Preloading video...", "Press Back to cancel");
progressDialog.show();
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog1) {
finish();
}
});
final VideoView view = (VideoView)findViewById(R.id.videoPlayer);
view.setMediaController(new MediaController(this));
view.setVideoURI(Uri.parse(getIntent().getExtras().getString("uri")));
view.requestFocus();
view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
view.start();
}
});
}
}
和XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView android:id="@+id/videoPlayer"
android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>
答
该解决方案:::D
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=VIDEOID"));
intent.putExtra("force_fullscreen",true);
startActivity(intent);
+0
这是官方吗?它是否写在任何地方?如果是这样,我还可以使用其他什么东西? –
你管的链接和视频链接之间的区别是什么?都是url的权利? – Udaykiran
它们都是网址,但有一点指向包含视频播放器,评论,相关内容等的Youtube页面,而另一个则是视频本身的网址。你可以使用这样的网站来更换一个到另一个:http://keepvid.com/?url –