开发者

How to add a controller in android to search in a video

I am pretty new in developing apps for Android so I need your experienced help.

How can I add a video controller, a bar to search in the video lenght? I tried to add s开发者_StackOverflow中文版ome code lines from android guide but I get blank screen

Here's a link 2 screen shots

http://www.wocmultimedia.com/screenshot1.jpg

http://www.wocmultimedia.com/screenshot2xml.jpg

the activity is named controlbar.java the layout clip2.xml the videoclip corsolex_1.mp4 and is set in res/raw folder

Thank you very much. Have a good day. Angelo

public class controlbar extends Activity {
  @Override protected void onCreate (Bundle savedInstanceState){ 
    //TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.clip2); 
    VideoView videoView = (VideoView) findViewById(R.id.videoView1); 
    Uri videoPath = Uri.parse("android.resource://" + getPackageName() + 
        "/" + R.raw.corsolex_1); 
    videoView.setVideoURI(videoPath); 
    videoView.setMediaController(new MediaController(this)); 
    videoView.requestFocus(); 
    videoView.start(); 
  } 
} 

layout clip2.xml

<FrameLayout 
    android:id="@+id/frameLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="schemas.android.com/apk/res/android"
    >
  <VideoView 
      android:id="@+id/videoView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      >
  </VideoView> 
</FrameLayout>


You need to add a few buttons for play and pause, and a SeekBar to set the video play position (using VideoView#seek(long) inside a SeekBar.OnSeekBarChangeListener).

Since I don't see any Button in your code, I would suggest you to start by reading the dev guide first (e.g., the handling UI events page) and trying first some of the tutorials (here).

You can then try to apply what you learned to your project, and come back with more specific questions.

And, BTW, click on my edit to your post so you can learn how to post the code in there :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜