adb push /path/on/workstation/video.mp4 /sdcard

In the code, use the SD card path for the setDataSource() call:

mMediaPlayer.setDataSource("/sdcard/video.mp4");

On Jan 16, 9:06 pm, "Mahesh Vaghela" <mah...@indianic.com> wrote:
> Hi Dave,
>
> I like your line:
> *
> "As a first step, I would try pushing it to the SD card and playing it from
> there."*
>
> Can you please show a way to push a mp4 or mp3 file in a sd card?
>
> On Sat, Jan 17, 2009 at 6:46 AM, Dave Sparks <davidspa...@android.com>wrote:
>
>
>
>
>
> > Can you be a bit more explicit when you say "nothing happens"?
>
> > Usually - no matter what kind of bug you might have - something
> > happens, it's just not what you expected to happen. For example, do
> > you have log output?
>
> > My guess is that you cannot use an MP4 as a raw resource because it
> > gets compressed. I can't recall if we exclude it or not, but you
> > normally don't want to bundle a resource like a video file into your
> > resources. As a first step, I would try pushing it to the SD card and
> > playing it from there.
>
> > On Jan 16, 7:49 am, srini amul <srinia...@yahoo.com> wrote:
> > > Below is a step which i tried to play a mp4 file. But nothing happens.
> > Could someone please help me out ?
>
> > > Steps which I tried:
> > > *******************************
> > > a) I added a SurfaceView element in main.xml
> > > b) I uploaded a video.mp4 file in res/raw directory
>
> > > Below is my main.xml:
> > > ----------------------
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
> > >     android:orientation="vertical"
> > >     android:layout_width="fill_parent"
> > >     android:layout_height="fill_parent"
>
> > > <SurfaceView android:id="@+id/SurfaceView01"
> > >     android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:clickable="true"></SurfaceView>
> > > </LinearLayout>
>
> > > Below is my application code:
> > > ------------------------------------------
>
> > > package android.videoPlayer;
>
> > > import java.io.IOException;
>
> > > import android.app.Activity;
> > > import android.media.AudioManager;
> > > import android.media.MediaPlayer;
> > > import android.media.MediaPlayer.OnBufferingUpdateListener;
> > > import android.media.MediaPlayer.OnCompletionListener;
> > > import android.media.MediaPlayer.OnPreparedListener;
> > > import android.os.Bundle;
> > > import android.util.Log;
> > > import android.view.SurfaceHolder;
> > > import android.view.SurfaceView;
> > > import android.view.SurfaceHolder.Callback;
>
> > > public class videoPlayer extends Activity implements Callback,
> > OnBufferingUpdateListener, OnPreparedListener, OnCompletionListener {
> > > private static final String TAG = "VideoPlayerDemo";
> > > private int mVideoWidth;
> > > private int mVideoHeight;
> > > private MediaPlayer mMediaPlayer;
> > > private SurfaceView mPreview;
> > > private SurfaceHolder holder;
>
> > > /** Called when the activity is first created. */
> > > @Override
> > > public void onCreate(Bundle savedInstanceState)
> > > {
> > > super.onCreate(savedInstanceState);
> > > setContentView(R.layout.main);
>
> > > mPreview = (SurfaceView) findViewById(R.id.SurfaceView01);
> > > holder = mPreview.getHolder();
> > > holder.addCallback(this);
> > > holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>
> > > }
>
> > > private void playVideo() {
>
> > > // Create a new media player and set the listeners
> > > mMediaPlayer = MediaPlayer.create(this, R.raw.mp4);
> > > mMediaPlayer.setDisplay(holder);
> > > try {
> > > mMediaPlayer.prepare();} catch (IllegalStateException e) {
>
> > > // TODO Auto-generated catch block
> > > e.printStackTrace();} catch (IOException e) {
>
> > > // TODO Auto-generated catch block
> > > e.printStackTrace();}
>
> > > mMediaPlayer.setOnBufferingUpdateListener(this);
> > > mMediaPlayer.setOnCompletionListener(this);
> > > mMediaPlayer.setOnPreparedListener(this);
> > > mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
>
> > > }
>
> > > public void onBufferingUpdate(MediaPlayer arg0, int percent) {
> > > Log.d(TAG, "onBufferingUpdate percent:" + percent);
>
> > > }
>
> > > public void onCompletion(MediaPlayer arg0) {
> > > Log.d(TAG, "onCompletion called");
>
> > > }
>
> > > public void onPrepared(MediaPlayer mediaplayer) {
> > > Log.d(TAG, "onPrepared called");
> > > mVideoWidth = mMediaPlayer.getVideoWidth();
> > > mVideoHeight = mMediaPlayer.getVideoHeight();
> > > if (mVideoWidth != 0 && mVideoHeight != 0) {
> > > holder.setFixedSize(mVideoWidth, mVideoHeight);
> > > mMediaPlayer.start();
>
> > > }
> > > }
>
> > > public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int
> > k) {
> > > Log.d(TAG, "surfaceChanged called");
>
> > > }
>
> > > public void surfaceDestroyed(SurfaceHolder surfaceholder) {
> > > Log.d(TAG, "surfaceDestroyed called");
>
> > > }
>
> > > public void surfaceCreated(SurfaceHolder holder) {
> > > // TODO Auto-generated method stub
> > > Log.d(TAG, "surfaceCreated called");
> > > playVideo();
>
> > > }
>
> > > @Override
> > > protected void onDestroy() {
> > > super.onDestroy();
> > > // TODO Auto-generated method stub
> > > if (mMediaPlayer != null) {
> > > mMediaPlayer.release();
> > > mMediaPlayer = null;
>
> > > }
> > > }
> > > }
>
> > >       Connect with friends all over the world. Get Yahoo! India Messenger
> > athttp://in.messenger.yahoo.com/?wm=n/
>
> --
> Mahesh Vaghelahttp://www.indianic.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to