Thanks in advance : )

On 4月8日, 下午6时13分, fubin <[EMAIL PROTECTED]> wrote:
> Why does the following code failed? I just want switch between
> different files. But the application crashed again and again
>
> package com.google.android.samples.media.test;
>
> import android.app.Activity;
> import android.graphics.PixelFormat;
> import android.net.Uri;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.Button;
> import android.widget.MediaController;
> import android.widget.VideoView;
>
> public class VideoViewDemo extends Activity {
>     /** Called when the activity is first created. */
>     private String path = "/data/room.mp4";
>     private VideoView mVideoView;
>
>     @Override
>     public void onCreate(Bundle icicle) {
>         super.onCreate(icicle);
>         getWindow().setFormat(PixelFormat.TRANSLUCENT);
>         setContentView(R.layout.videoview);
>         mVideoView = (VideoView) findViewById(R.id.surface_view);
>         MediaController nc = new MediaController(this);
>         mVideoView.setMediaController(nc);
>         mVideoView.requestFocus();
>
>         Button b1 = (Button)findViewById(R.id.button1);
>         Button b2 = (Button)findViewById(R.id.button2);
>
>         b1.setOnClickListener(new OnClickListener(){
>                         @Override
>                         public void onClick(View view) {
>                                 // TODO Auto-generated method stub
>                                 mVideoView.pause();
>                                 mVideoView.stopPlayback();
>                                 mVideoView.setVideoPath("XXXXPATH1.MP4");
>                         }
>         });
>         b2.setOnClickListener(new OnClickListener(){
>                         @Override
>                         public void onClick(View view) {
>                                 // TODO Auto-generated method stub
>                                 mVideoView.pause();
>                                 mVideoView.stopPlayback();
>                                 mVideoView.setVideoPath("XXXXPATH2.MP4");
>                         }
>         });
>     }
>
> }
>
> On 4月8日, 上午12时39分, fubin <[EMAIL PROTECTED]> wrote:
>
> > The VideoView example works fine when play just a sigle mp4 file, But
> > I wander if I can pause the current playing file and setpath to
> > another file ? I tried but it failed.
>
> > how should I do if I want to switch between different mp4 files while
> > the previous one is not finished?
>
> > I use the following code to set a new file  to a videoview:
> >                         if (mVideoView.isPlaying()) {
> >                                 mVideoView.pause();
> >                                 mVideoView.stopPlayback();
> >                         }
> >                         mVideoView.setVideoPath("XXXXX.mp4");
> >                         mVideoView.setMediaController(mMediaController);
>
> > Is there anything wrong?
> > The result is the first runing file paused, and the second file can
> > not run. when switch back to the previous one, it crashed
>
> > (BTW, the videoview widget seems resource consuming, It can't work on
> > my old T42 notebook with 1G memory, 1.7G cpu 1core, the application
> > die often,  but on T61 with 2 core CPU, it works just as expected...)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to