MediaPlayer does support streaming, but in this case, setDataSource should have Uri as the input, rather than a String input just like you used in your code. Hope it helps.
On 5月22日, 上午11时57分, Priya <[email protected]> wrote: > Hi, > > here is my code for playing video through url.... > > public class sample extends Activity { > > private String _videoPath; > privateMediaPlayer_mp; > private static final String TAG = "Video"; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > _videoPath = "http://16.181.151.159/video/funnydog.wmv"; > > getWindow().setFormat(PixelFormat.TRANSLUCENT); > > LinearLayout layout = new LinearLayout(getBaseContext()); > layout.setLayoutParams(new LinearLayout.LayoutParams > (LinearLayout.LayoutParams.FILL_PARENT, > > LinearLayout.LayoutParams.FILL_PARENT)); > > SurfaceView sview = new SurfaceView(getBaseContext()); > sview.setLayoutParams(new LinearLayout.LayoutParams > (320,180)); > sview.getHolder().addCallback(new surfaceHolderCallback()); > > layout.addView(sview); > setContentView(layout); > } > > class surfaceHolderCallback implements SurfaceHolder.Callback { > public void surfaceCreated(SurfaceHolder holder) { > try { > _mp = newMediaPlayer(); > _mp.setDataSource(_videoPath); > _mp.setDisplay(holder); > > _mp.setOnPreparedListener(new > MediaPlayer.OnPreparedListener() { > public void onPrepared(MediaPlayermediaPlayer) { > mediaPlayer.start(); > } > }); > > _mp.setOnErrorListener(newMediaPlayer.OnErrorListener > () { > public boolean onError(MediaPlayermediaPlayer,int > i, int i1) { > Log.e(TAG, Integer.toString(i)); > return false; > } > }); > > _mp.prepareAsync(); > > } catch (Exception ex) { > Log.e(TAG, ex.getMessage()); > } > } > > public void surfaceChanged(SurfaceHolder surfaceHolder, int i, > int i1, int i2) { > } > > public void surfaceDestroyed(SurfaceHolder surfaceHolder) { > _mp.stop(); > _mp.release(); > } > } > > } > > I am getting Error(-1,0) ... can anybody resolve this issue... > > Thanks > Priya > > On May 21, 1:29 pm, Priya <[email protected]> wrote: > > > Hi, > > > I am new to Android. > > I have depeloped a video player app. through Sd card. > > > Now i want to play video direct from URL. > > > Can anybody provide me sample code for the same. > > > Thanks in advance... > > > Thanks > > Priya --~--~---------~--~----~------------~-------~--~----~ 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] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

