You can use res/raw for audio files that aren't too large. As I said
earlier, I think the problem with video files is that the appt
compiler compresses them. You could decompress them yourself and copy
them to the SD card. Or you could download the files from a server
when the application installs.

On Jan 19, 3:30 am, "Mahesh Vaghela" <mah...@indianic.com> wrote:
> Hi Dave,
>
> Thanks for the info.
> Finally I have decided to put all my audio data to SD card.
> I can do this as suggested by you for a manual check.
>
> *"adb push /path/on/workstation/video.mp4 /sdcard"*
>
> This will work on my emulator.
> If I want to do this for a real device than my code should first push all my
> audio data in the user's SD card.
>
> Can you please show me a way how to do this?
>
> Is there any predefined folder like drawable/raw (Or some other like this)
> which can directly put our data in sdcard instead of application's private
> folder?
>
> On Sun, Jan 18, 2009 at 1:34 AM, Dave Sparks <davidspa...@android.com>wrote:
>
>
>
>
>
> > You can call android.os.Environment.getExternalStorageDirectory() to
> > get the path to the external storage device. That will handle the case
> > where recommended external store is no the SD card but some other
> > device.
>
> > If there is no external storage, you can try saving to your app's
> > private data directory. Another alternative it to stream the media
> > from a server, but this obviously introduces the complexity and cost
> > of maintaining the service for your users.
>
> >  All of the Android standard apps (camera, music, sound recorder) that
> > create or use media files assume that the device will have external
> > storage. In the end, you have to decide whether it's worth supporting
> > users that don't have external storage.
>
> > On Jan 17, 1:29 am, "Mahesh Vaghela" <mah...@indianic.com> wrote:
> > > Dave,
>
> > > Thank you very much for replying soon. I understand how to push my mp4 in
> > a
> > > sd card and retrive the same.
>
> > > I am a bit curious to know limitation of doing this.
>
> > > 1. sd card may not be an part of all the Android devices.
> > > 2. If it is the case, all users may not purchase it as an extra item
> > > considering extra cost.
> > > 3. If so, an application which reads only from  an sd card may not work
> > > properly on all devices.
>
> > > Can you please guide me if there is an alternate way for storing the
> > media
> > > files? I know I can directly keep this in, with my apk under raw folder,
> > but
> > > this will made an application larger to download.
>
> > > The total disk size available for an android application is only 70 mb.
> > So
> > > one has to think for keeping his apk size to minimum.
>
> > > On Sat, Jan 17, 2009 at 12:57 PM, Dave Sparks <davidspa...@android.com
> > >wrote:
>
> > > > 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
>
> > > --
> > > Mahesh Vaghela
>
> > >http://www.indianic.com
>
> --
> | Mahesh Vaghela | Sr. Developer - Dotnet
> | IndiaNic Infotech Ltd.|
> | 7th Floor, Gopal Palace, Nehrunagar Road, Ahmedabad-38006
> ***************************************************
> | Phone No. (079 )( 26404209) | 1-(310)-909-8707
> | Visit us at: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