HI 我想在android手机发挥.3GP视频文件。我试图跌破code,但它显示着玩video.so请告诉我,我会做什么
这是我的code
公共类VideoPlay延伸活动{
私人字符串路径;
私人VideoView mVideoView;
@覆盖
公共无效的onCreate(包冰柱){
super.onCreate(冰柱);
的setContentView(R.layout.videoplay);
路径=http://www.boodang.com/api/videobb/101009_Pure.3gp;
mVideoView =(VideoView)findViewById(R.id.video);
如果(路径==){
//告诉用户提供媒体文件的URL /路径。
Toast.makeText(
VideoPlay.this,
请编辑VideoViewDemo活动,并设置路径
+变到你的媒体文件的网址/路径,
Toast.LENGTH_LONG).show();
} 其他 {
/ *
*另外,流媒体可以使用
* mVideoView.setVideoURI(Uri.parse(URLstring));
* /
mVideoView.setVideoPath(路径);
mVideoView.setMediaController(新的MediaController(本));
mVideoView.requestFocus();
}
}
}
中的XML布局
< XML版本=1.0编码=UTF-8&GT?;
<的FrameLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< VideoView
机器人:ID =@ + ID /视频
机器人:layout_width =320px的
机器人:layout_height =240px>
< / VideoView>
< /的FrameLayout>
解决方案
请检查下面的code这是有在Android SDK演示
包com.example.android.apis.media;
进口com.example.android.apis.R;
进口android.app.Activity;
进口android.os.Bundle;
进口android.widget.MediaController;
进口android.widget.Toast;
进口android.widget.VideoView;
公共类VideoViewDemo延伸活动{
/ **
* TODO:将PATH变量设置为视频流的URL或本地媒体
* 文件路径。
* /
私人字符串路径=;
私人VideoView mVideoView;
@覆盖
公共无效的onCreate(包冰柱){
super.onCreate(冰柱);
的setContentView(R.layout.videoview);
mVideoView =(VideoView)findViewById(R.id.surface_view);
如果(路径==){
//告诉用户提供媒体文件的URL /路径。
Toast.makeText(
VideoViewDemo.this,
请编辑VideoViewDemo活动,并设置路径
+变到你的媒体文件的网址/路径,
Toast.LENGTH_LONG).show();
} 其他 {
/ *
*另外,流媒体可以使用
* mVideoView.setVideoURI(Uri.parse(URLstring));
* /
mVideoView.setVideoPath(路径);
mVideoView.setMediaController(新的MediaController(本));
mVideoView.requestFocus();
}
}
}
videoview.xml
< VideoView
机器人:ID =@ + ID / surface_view
机器人:layout_width =320px的
机器人:layout_height =240px
/>
HI i want to play a .3GP video file in android phone. i tried below code but it shows cant play video.so please tell me what i will do
This is my code
public class VideoPlay extends Activity {
private String path ;
private VideoView mVideoView;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoplay);
path="http://www.boodang.com/api/videobb/101009_Pure.3gp";
mVideoView = (VideoView) findViewById(R.id.video);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoPlay.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
}
The XML layout is
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/video"
android:layout_width="320px"
android:layout_height="240px">
</VideoView>
</FrameLayout>
解决方案
Check the following code which is there in the Android SDK demo
package com.example.android.apis.media;
import com.example.android.apis.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class VideoViewDemo extends Activity {
/**
* TODO: Set the path variable to a streaming video URL or a local media
* file path.
*/
private String path = "";
private VideoView mVideoView;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoViewDemo.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
}
videoview.xml
<VideoView
android:id="@+id/surface_view"
android:layout_width="320px"
android:layout_height="240px"
/>