Show me the code! – By Davanum Srinivas

December 29, 2007

Android – Video/Music player sample (from local disk as well as remote URL’s)

Filed under: Uncategorized — Davanum Srinivas @ 11:25 pm

Dec-04-2009 : This post is outdated. Please look here for updated code

Here is a screen shot.

1

Notes



  • You can specify a directory path or a remote URL in the edit box

  • You can specify just an mp3 file to play music only

  • Choose any 3gp file from http://daily3gp.com/ to view videos

  • The 4 buttons are for play, pause, reset and stop

  • When you specify a http or https url, we save the url contents to hard disk first and then play it

  • All the leg work was done by dahui. Many thanks!!

  • The icons are from here

  • MediaPlayer does not yet support any remote url’s or MPEG4 video AFAICT

Here’s the code

package org.apache.android;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.webkit.URLUtil;
import android.widget.EditText;
import android.widget.ImageButton;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class VideoPlayer extends Activity implements OnErrorListener,
        OnBufferingUpdateListener, OnCompletionListener,
        MediaPlayer.OnPreparedListener, SurfaceHolder.Callback {
    private static final String TAG = "VideoPlayer";

    private MediaPlayer mp;
    private SurfaceView mPreview;
    private EditText mPath;
    private SurfaceHolder holder;
    private ImageButton mPlay;
    private ImageButton mPause;
    private ImageButton mReset;
    private ImageButton mStop;
    private String current;

    /**
     * Called when the activity is first created.
     */
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        setContentView(R.layout.main);

        // Set up the play/pause/reset/stop buttons
        mPreview = (SurfaceView) findViewById(R.id.surface);
        mPath = (EditText) findViewById(R.id.path);
        mPlay = (ImageButton) findViewById(R.id.play);
        mPause = (ImageButton) findViewById(R.id.pause);
        mReset = (ImageButton) findViewById(R.id.reset);
        mStop = (ImageButton) findViewById(R.id.stop);

        mPlay.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                playVideo();
            }
        });
        mPause.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.pause();
                }
            }
        });
        mReset.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.seekTo(0);
                }
            }
        });
        mStop.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.stop();
                    mp.release();
                }
            }
        });

        // Set the transparency
        getWindow().setFormat(PixelFormat.TRANSPARENT);

        // Set a size for the video screen
        holder = mPreview.getHolder();
        holder.setCallback(this);
        holder.setFixedSize(400, 300);
    }

    private void playVideo() {
        try {
            final String path = mPath.getText().toString();
            Log.v(TAG, "path: " + path);

            // If the path has not changed, just start the media player
            if (path.equals(current) && mp != null) {
                mp.start();
                return;
            }
            current = path;

            // Create a new media player and set the listeners
            mp = new MediaPlayer();
            mp.setOnErrorListener(this);
            mp.setOnBufferingUpdateListener(this);
            mp.setOnCompletionListener(this);
            mp.setOnPreparedListener(this);
            mp.setAudioStreamType(2);

            // Set the surface for the video output
            mp.setDisplay(mPreview.getHolder().getSurface());

            // Set the data source in another thread
            // which actually downloads the mp3 or videos
            // to a temporary location
            Runnable r = new Runnable() {
                public void run() {
                    try {
                        setDataSource(path);
                    } catch (IOException e) {
                        Log.e(TAG, e.getMessage(), e);
                    }
                    mp.prepare();
                    Log.v(TAG, "Duration:  ===>" + mp.getDuration());
                    mp.start();
                }
            };
            new Thread(r).start();
        } catch (Exception e) {
            Log.e(TAG, "error: " + e.getMessage(), e);
            if (mp != null) {
                mp.stop();
                mp.release();
            }
        }
    }

    /**
     * If the user has specified a local url, then we download the
     * url stream to a temporary location and then call the setDataSource
     * for that local file
     *
     * @param path
     * @throws IOException
     */
    private void setDataSource(String path) throws IOException {
        if (!URLUtil.isNetworkUrl(path)) {
            mp.setDataSource(path);
        } else {
            URL url = new URL(path);
            URLConnection cn = url.openConnection();
            cn.connect();
            InputStream stream = cn.getInputStream();
            if (stream == null)
                throw new RuntimeException("stream is null");
            File temp = File.createTempFile("mediaplayertmp", "dat");
            String tempPath = temp.getAbsolutePath();
            FileOutputStream out = new FileOutputStream(temp);
            byte buf[] = new byte[128];
            do {
                int numread = stream.read(buf);
                if (numread <= 0)
                    break;
                out.write(buf, 0, numread);
            } while (true);
            mp.setDataSource(tempPath);
            try {
                stream.close();
            }
            catch (IOException ex) {
                Log.e(TAG, "error: " + ex.getMessage(), ex);
            }
        }
    }

    public void onError(MediaPlayer mediaPlayer, int what, int extra) {
        Log.e(TAG, "onError--->   what:" + what + "    extra:" + extra);
        if (mediaPlayer != null) {
            mediaPlayer.stop();
            mediaPlayer.release();
        }
    }

    public void onBufferingUpdate(MediaPlayer arg0, int percent) {
        Log.d(TAG, "onBufferingUpdate called --->   percent:" + percent);
    }

    public void onCompletion(MediaPlayer arg0) {
        Log.d(TAG, "onCompletion called");
    }

    public void onPrepared(MediaPlayer mediaplayer) {
        Log.d(TAG, "onPrepared called");
    }

    public boolean surfaceCreated(SurfaceHolder surfaceholder) {
        Log.d(TAG, "surfaceCreated called");
        return true;
    }

    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");
    }
}

Download Source and APK from here – VideoPlayer.zip

161 Comments »

  1. Hi,
    Thanks for your code, It works like a charm but i need to know one thing where the temp file is created and is it not necessary to delete the temp file every time when the media is completed

    Comment by Navas — December 31, 2007 @ 1:39 am

    • Hey, How did you all guys worked this code? I’m not able run any video using this code. It runs on my device. when i play with the sdcard path ( file:///sdcard/a.mp4), it doesn’t run my video there. And i kept that as with default path also didn’t play any video. But i want to run a video which is from Raw folder available in project resource using this code…Can it be done? If yes, how? Please advice asap.

      Comment by John — October 16, 2009 @ 7:12 am

    • Hey could u please send code in a zip file. thanks in advance

      Comment by abhi — September 29, 2010 @ 11:35 pm

  2. Hi,

    I tried to run the code but I cannot import the project in Eclipse and when I create a new project and I try to copy the unzipped files over the created ones, some errors occur.

    Can you provide more informations on how to run this project?
    Thank you

    Comment by Liviu — December 31, 2007 @ 9:07 am

  3. […] has also made the source available, which can be found here. SHARETHIS.addEntry({ title: “A New Media Player for Android”, url: […]

    Pingback by A New Media Player for Android | DroidSpot — December 31, 2007 @ 11:02 pm

  4. Hi,

    I download the application and unable to run the same in eclipse. It showing some exception in Androidmanifest.xml file.

    It showing “package ‘ org.apache.android’ does not exist! “. what i suppose to do for this.

    Thanks,
    Bala.

    Comment by Balaji — January 24, 2008 @ 5:03 am

  5. Hi,

    I have created one more file in that i added all the files present in the VideoPlayer.zip.

    Finally i got something, but with simple text box alone, nothin other than that is comming .

    Kindly help me in this regrds.

    Bala.

    Comment by Balaji — January 24, 2008 @ 6:07 am

  6. Hi,

    Is there any way to start video playback from a service?

    Comment by Rohit — January 28, 2008 @ 1:38 am

  7. Thanks for a great demo!
    Simple, elegant and well-written.

    Comment by Amos — January 31, 2008 @ 4:48 pm

    • hi,
      Pls cud u send me code in a zip file pls. thx in advance

      Comment by abhi — September 29, 2010 @ 11:39 pm

  8. Hi,

    Could you please update this to work with M5.

    Thanks,

    Regards

    Comment by gary silva — February 17, 2008 @ 9:44 pm

    • hi,
      Pls cud u send me VideoPlayer code in a zip file pls. thx in advance

      Comment by abhi — September 29, 2010 @ 11:40 pm

  9. Very nice example. For those who have problem to run it:
    How it is written one will need to use HVGA-L mode of emulator or to edit the following line inside onCreate:
    holder.setFixedSize(400, 300);
    to something less ambitious like 200×200.

    Comment by Filip Bulovic — February 24, 2008 @ 1:45 pm

  10. Hi,
    Can you update this player to M5 please!

    Tanks.
    Andrew

    Comment by Andrew — March 5, 2008 @ 2:50 pm

  11. Thanks for a great demo!

    Comment by Deri — March 23, 2008 @ 1:06 pm

  12. Hi,
    Could you update this player to M5 please!
    thanks

    Comment by peng — April 24, 2008 @ 10:13 pm

  13. Hi .
    I can’t play the video from the local . the error as follows:
    Duration: ===> -1
    Could you help me check it .Thansk

    Thanks.

    Comment by peng — April 28, 2008 @ 2:35 am

  14. peng i am also gtting th same problem … as in Dalvik debug monitor showing th duration as -1

    Comment by Dinesh — May 12, 2008 @ 7:48 am

  15. hv u found the solution for tat .. if so help me out ..

    Comment by Dinesh — May 12, 2008 @ 7:49 am

  16. Hi,

    This code is showing some errors.
    Actually the setCallback method is not avalable in m5. And the surfaceCreated method’s return type has been changed.

    i updated these errors. but am not able toplay any file. Please help me.

    Comment by radhika — May 13, 2008 @ 7:29 am

  17. may i have a look at your main file? thanks!

    Comment by abc — May 20, 2008 @ 10:46 pm

    • hi,
      Pls cud u send me VideoPlayer code in a zip file pls. thx in advance.

      Comment by abhi — September 29, 2010 @ 11:41 pm

  18. hi……

    i have the proble with the video view i will post my code down …….its not working…

    [syntax=”java”]
    Java:
    import android.net.Uri;
    import android.os.Bundle;
    import android.widget.VideoView;
    public class musicplayer extends Activity {

    @Override
    public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    setContentView(R.layout.main);
    VideoView vv=(VideoView)findViewById(R.id.vdoplayer);
    // MediaPlayer mp=new MediaPlayer();

    // Uri myUrl = Uri.parse(“http://207.210.108.32/Music/Crazy.3gp”);
    // vv.setVideoURI(myUrl);
    vv.setVideoPath(“http://207.210.108.32/Music/Alarm.wmv”);
    vv.start();

    }
    }

    this is the java file andd xml given below

    XML:
    ]syntax=”xml”]

    but is not working…..i was trying with the my own server….it is getting in browser….but not working with the video view…….can any body help me…….

    or can any body tell me how to access and play video on the emulator …..

    please…
    with thanks bins……..

    Comment by bins — May 22, 2008 @ 6:43 am

  19. Hi,
    thanks a lot for that example!
    1. I can play videos from the internet when i remove the extra thread and start & prepare the player without it. Do you really need an extra thread? The GUI is reacting nevertheless, so whats the advantage?
    2. How can i play local files? I put them into the resource folder (res/raw/), but no path which i enter in the textfield seem to be correct.

    thanks for help

    Comment by alex — May 28, 2008 @ 7:58 am

    • hi,
      Pls cud u send me VideoPlayer code in a zip file pls. thx in advance..

      Comment by abhi — September 29, 2010 @ 11:41 pm

  20. Ok,
    i figured out a way to play local videos. If you play them from the Internet, they get stored in /tmp/… I just copied a video over eclipse FileExplorer into that directory and played the url /tmp/filename. But i donĀ“t know how to play files within the resources directory. Most likely they are stored in the app.apk. Why canĀ“t i play them with /res/raw/filenname?

    Comment by alex — May 28, 2008 @ 10:19 am

  21. Hi,
    This is really great and thanks for sharing this code. but
    can anybody tell me where is the zip file for this source code?

    else let me know how to run this code in android emulator?

    Thanks,
    Souvik

    Comment by souvik — June 16, 2008 @ 2:37 am

  22. Problem: Not able to load the project into Eclipse.
    when I want to add this project as new project from existing source and given the path for this folder , its showing an error msg:” No activity name defined in D:\android\android_workspace\VideoPlayer\AndroidManifest.xml.”

    and not able to load this project.
    Please help me to load this project to run it in emulator.
    Thanks,
    Souvik

    Comment by souvik — June 16, 2008 @ 4:03 am

  23. Hi,

    I could resolve all the errors. I’m finding problem at the run time. I’m getting NullPointerException error. Found that the error is due to
    mPreview = (SurfaceView) findViewById(R.id.surface)
    mPreview is null.
    Likewise, mPath, mPlay, … are also null.

    Can anyone suggest how to overcome this issue???????

    Celia

    Comment by celia — June 20, 2008 @ 4:02 am

  24. Hi, Change the id to android:id in main.xml.
    You will see the layout by the above modification.

    Comment by Prahlad T — July 7, 2008 @ 1:28 am

  25. hi there..
    from above pasted code.. when i did some changes at line number 122.. i just cut that line and put out of thread then only it is working fine for total video lenght.

    otherwise if i keep it as it is in thread then only very small fraction of video from initial part is playing then after it is terminating application…

    can you help me in that .,…?

    Comment by nekin — July 9, 2008 @ 5:43 am

  26. Does anybody here know a valid and updated code that works fine? šŸ˜¦

    Comment by ricardo souza — July 15, 2008 @ 7:21 am

  27. I have some problem on
    final String path = mPath.getText().toString();

    when I run the program..
    java.nullpointer exception occur..
    can someone help me?
    thx in advanced

    Comment by hendrik — July 24, 2008 @ 9:15 pm

  28. Hi!,

    Comment by name — August 31, 2008 @ 10:40 pm

  29. Hi,

    I can’t see the source code. I got web page not found exception if I’m trying to download the source code.

    Can you plz… anybody share the source code ?

    Thanks in advance.

    Comment by Yasmin — October 20, 2008 @ 10:53 pm

  30. The source and pictures are no longer available. If you still have the source, could you please email it to me ? Thank you !

    Comment by Tim — October 24, 2008 @ 11:25 am

    • If you got all the codes then please email to me….i in very much need of that code.

      Comment by vijay — November 16, 2009 @ 4:08 am

  31. Hallo ,

    great Work ,but i can’t play it with the 0.9 Beta ,Could you please help me and mail me this .

    thanks

    Comment by Ami — November 5, 2008 @ 9:47 am

  32. hi,
    i cant able to download the code canu pls share the code

    i have copied and run it i am getting error

    MediaPLayer :Error(-38,0)
    Error(-1,0)
    will u pls help me ou of this

    thanxin advance

    Comment by babavali — November 21, 2008 @ 1:28 am

  33. hi,
    where is the source file? I got web page not found exception 404 whie downloading the source code.

    can anybody share the code pls….
    my id is alpesh.harsoda@gmail.com

    thnks in advance.

    Regards,
    Alpesh Harsoda

    Comment by Alpesh — December 8, 2008 @ 4:34 am

  34. Hi,
    I tried this code by make some necessary changes. but not working can you please help me. Its giving the NullPointerException at surface view,giving error(-38,0). Some where it showing Status=#fffffff

    Comment by ankit somani — December 13, 2008 @ 3:42 pm

  35. Can anybody share the source code?
    I couldn’t download the code.

    Please…

    my email is cindyduh@nthu.us

    thanks a lot!

    Comment by cindy — December 18, 2008 @ 7:45 am

  36. Please share the Video Player Code .. Since it is not downloadable from this site

    Comment by Nikhil — January 25, 2009 @ 3:52 am

  37. my email id is nikhilbhandary@gmail.com
    Please share the Video Player Code .. Since it is not downloadable from this site

    Comment by Nikhil — January 25, 2009 @ 3:56 am

  38. Can anybody please share the source code? The download link is not working. email: high2freq@yahoo.com

    Thanks.

    Comment by Andrea — January 26, 2009 @ 3:40 am

  39. Yes, I would appreciate the code also. My email is aphilsmith@gmail.com

    Thanks!

    Comment by Phil — January 26, 2009 @ 3:17 pm

  40. can you please email me the ZIP file as its no longer downloadable from this site?
    i desperately need it.

    Comment by anushka — January 27, 2009 @ 1:04 pm

    • give me your id.. i can send it on your id…

      Comment by nextcome — May 6, 2010 @ 1:57 am

      • please mail the code to me as well. asap !!!

        Comment by shailesh — November 14, 2010 @ 11:21 pm

  41. please email me the ZIP file as its no longer downloadable from this site?
    i desperately need it.

    Comment by anushka — January 27, 2009 @ 1:05 pm

  42. can anybody pleaseeeeeee email this file to me… as i’m not able to download the zip file from this site…PLeaseeeeee
    email : varsha.uni@gmail.com

    Comment by Varsha — February 2, 2009 @ 6:11 pm

  43. Many thanks to this code.

    The lik to zip file is not available. Is this been removed from the server?

    I am trying use the code mentioned above. I could not compile it. It saying R.ID is not recognized. Can someone give me strps to compile this code. What are other files needed or what declaration are needed to compile this successfully?

    Thank you for your time.

    Comment by vishy — February 3, 2009 @ 1:39 am

  44. Dear, Can some one share the code to update the Progress bar of the Media playback?

    Comment by vishy — February 5, 2009 @ 10:23 am

  45. Please share source code with me, as this has been removed from server. my email id is jayesh.thadani@gmail.com

    Comment by jayesh — February 5, 2009 @ 11:52 pm

  46. The link to the sourcecode does not exist. Can you share the latest zip file at pbdnit@yahoo.com pls ?

    Comment by Gate — February 13, 2009 @ 2:51 pm

  47. Can anybody please share the source code? The download link is not working. email: mrcararia@gmail.com

    Thanks.

    Comment by Mr. Cararia — February 16, 2009 @ 6:00 am

  48. Hey guyz.. plz i need this code .. so could u ppl send this code on this email add: javeeduddin.b@hotmail.com

    Comment by Javed — February 20, 2009 @ 12:14 am

  49. Can anybody please share the source code? The download link is not working. email: smartcelldebono@yahoo.com

    Thanks.

    Comment by Smartcell — February 26, 2009 @ 12:21 pm

  50. The download able zip code is not available on this link. can you pls send it to me in mail? muthusankarm@hotmail.com

    Comment by muthu — March 3, 2009 @ 6:44 am

  51. Hey, could you please send me(or update the download link) the source code of this app? I need it for a future-android-streaming app i’m developing. Thanks in advance! (Email: tdr.popa@gmail.com)

    Comment by tudor — March 8, 2009 @ 11:41 am

  52. Please share source code with me, as this has been removed from server. my email id is linesaver@gmail.com

    Comment by linesaver — March 9, 2009 @ 12:55 am

  53. some to me… where is the source šŸ™‚
    please info to: ilovesinai@gmail.com

    Comment by chris — March 9, 2009 @ 4:32 am

  54. pls send me the source code to shaks@ureach.com

    Comment by shakeel — March 10, 2009 @ 10:09 pm

  55. Hi their,
    I would like to have the Video/Musik player, so please can anyone send me the source code. e-Mail: m.kruemmling@googlemail.com

    Comment by Michael — March 25, 2009 @ 9:15 am

  56. Please share source code with me, as this has been removed from server. my email id is devadrita.harh@gmail.com

    Comment by Devadrita — March 28, 2009 @ 1:14 pm

  57. cant download source from that link -.-” can u send to my email? embedzit@gmail.com

    thx lotz

    Comment by suesi tan — March 30, 2009 @ 3:43 am

  58. Hi, can’t download the Zip-File. Can pleas send me the code to gurkenlager@googlemail.com

    Thanks!!!

    Comment by Gurke — April 2, 2009 @ 8:37 am

  59. I can’t download the zip file from the link. Please send me the file to hsyun@sktelecom.com Thank you in avanced!

    Comment by Harrison — April 23, 2009 @ 2:13 am

  60. Please share the code to me at my email id: apanwar@live.com as it is not downloadable from the link.
    Thanks,
    Amit

    Comment by Amit Panwar — April 24, 2009 @ 9:53 am

  61. I canā€™t download the zip file from the link. Please send me the file to emily.ting@ecs.com.tw Thank you in avanced!

    Comment by emily — April 29, 2009 @ 7:41 am

  62. Hi,i’m starting learning android now and this is really helpful to me,thanks for making it public.

    Can i have the source code at fidevel@yahoo.com,since its not downloadable from the link?Thanks in advance!

    3m

    Comment by fidevel — April 30, 2009 @ 8:23 am

  63. nice work man can i have the source code at my email id
    here it is kl_jander@yahoo.com thanks

    Comment by ben — May 1, 2009 @ 4:40 am

  64. Can anybody please share the source code? I desperately need it. thanks.
    recl24@hotmail.com

    Comment by rudi — May 4, 2009 @ 1:50 am

  65. Can anybody please share the source code? I desperately need it. thanks.
    hinty_ollo@hotmail.com

    Comment by sabrina — May 17, 2009 @ 10:01 pm

  66. I can’t download source code. Please Share the source code..
    lakdong@hotmail.com

    Comment by ldsung — May 18, 2009 @ 1:34 am

  67. Can you please share the source code ? Thanks a lot !

    Comment by Jesslyn — May 19, 2009 @ 5:23 pm

  68. I canā€™t download source code. Please Share the source code..
    bhwon@pyroworks.co.kr

    Comment by bhwon — May 20, 2009 @ 12:47 am

  69. I canā€™t download source code. Please Share the source code. Thanks a lot.

    color47@gmail.com

    Comment by Color — May 21, 2009 @ 4:20 am

  70. Can somebody send source zip file to me?
    I am stuck with running live video streaming part šŸ˜¦
    TIA

    Comment by Aahna — May 28, 2009 @ 3:26 am

  71. Can you please share the source code ? Thanks a lot !

    Comment by poveteen — June 1, 2009 @ 10:28 pm

  72. Can you please share the source code ? Thanks a lot !

    poveteen@gmail.com

    Comment by poveteen — June 1, 2009 @ 10:29 pm

  73. other solution pages from davanum have the zip file downloadable. Any particular reason why this link is disabled?
    It would be great help if people who got it earlier upload the same zip somewhere and share the link for helping others.
    Regards,
    Aahna

    Comment by Aahna — June 3, 2009 @ 1:12 am

  74. […] serie de manuales (http://www.android-spa.com/manuales.php)Reproductor multimedia (https://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-…) Posted: sĆ”bado, 06 de junio de 2009 10:52 por Thempra Archivado en: Software […]

    Pingback by Thempra.NET : Enlaces para iniciarse en la programacion sobre Android — June 6, 2009 @ 4:19 am

  75. Can anybody please share the source code? I desperately need it. thanks.

    shiihs5286@gmail.com

    Comment by Skono — June 9, 2009 @ 1:10 am

  76. I canā€™t download the zip file from the link. Please send me the file to shiihs5286@gmail.com Thank you in avanced!

    Comment by shiihs — June 9, 2009 @ 1:42 am

  77. hey hi buddy …
    cn i get source code of same.. it will be gr8 help fr me if i get code .. thnx in advance ..:)

    Comment by tushar — June 9, 2009 @ 9:35 am

  78. how to get those 4 image button displayed?

    Comment by alan — July 2, 2009 @ 3:17 pm

  79. very well presented. thank you.
    can you please help ? I want to install the android apk in a real device. how? procedure?

    Comment by mathew — July 28, 2009 @ 6:18 am

  80. Has anybody extended on this design? I listen to folder based audio courses and most media players are not very good at helping me managing them.

    I really like that this app starts with a folder view and it would be great if you could just say “play this folder” so that when one file finished it would load and play the next file. Even better if it remembered which file you were on and the location within that file per directory.

    And of course work with the bluetooth control buttons on my stereo headset and behave nicely when switching from audio to phone and back again.

    Any ideas where I can find an app like that?

    Comment by Dave — August 9, 2009 @ 8:21 pm

  81. hallo,
    I’m programming with Eclipse IDE and using the Android Emulator.I have make a copy and paste of this code, but I’m getting some errors with the class R.id.Thats is the class R.Java that was generated by creation of the application. I don’t know what is wrong on it. If it is correct what could be the problem. Could somebody help me ?

    public final class R {
    public static final class attr {
    }
    public static final class drawable {
    public static final int icon=0x7f020000;
    }
    public static final class layout {
    public static final int main=0x7f030000;
    }
    public static final class string {
    public static final int app_name=0x7f040001;
    public static final int hello=0x7f040000;
    }
    }

    Comment by stephane — August 13, 2009 @ 7:44 am

  82. hi, the download link is failed, could u send me the source file? i think it can help me to develop code about media player. thanks. my email: maestro1230@gmail.com

    Comment by Brian — September 14, 2009 @ 7:24 am

  83. Hey! can someone share the src with me? markmathis@gmail.com

    Comment by mark mathis — September 22, 2009 @ 5:54 am

  84. Hi,
    i cannot find the source files! can anyone please mail it to me(bhavyaprakash@gmail.com)
    Thanks a ton!

    Comment by Bhavya — September 23, 2009 @ 5:24 am

  85. Hi
    can any one share the APK file and the source code too
    pl. send to sayiram.kothuri@gmail.com

    Comment by sram — October 10, 2009 @ 3:02 am

  86. Hey! can someone share the src with me? kimjs0928@hanmail.net

    Comment by kim — October 26, 2009 @ 11:40 am

  87. will you please send me the source and apk to my email address as it giving some problem to download.

    Comment by gour — November 10, 2009 @ 12:02 pm

  88. Hi

    Can u please mail me the source code to my email address.

    Thanks in advance

    Comment by Urgent — November 20, 2009 @ 5:40 am

  89. Hi ,
    I am unable to download videoplayer.zip
    is it moved ?

    Comment by vasundhar — December 2, 2009 @ 4:24 am

  90. Hi,

    I’m unable to download videoplayer.zip, too. Could you please re-upload or send to me by email: ngoquanghuy.info@gmail.com

    Thanks for all!
    Huy

    Comment by Huy — December 20, 2009 @ 10:30 pm

  91. Hi,
    Iā€™m unable to download videoplayer.zip, too. Could you please re-upload or send to me by email : rocker0423@nate.com
    Thanks for all!!!

    Comment by red — December 25, 2009 @ 2:19 pm

  92. Hello all,

    When I tried to build the code in eclipse I got the following error. Can you pls tell me what to do . I am a newbie to adroid and java as well.. šŸ˜¦

    Description Resource Path Location Type
    R.id cannot be resolved VideoViewDemo.java /VideoViewDemo/src/org/apache/android/media line 53 Java Problem

    battus

    Comment by battus — January 6, 2010 @ 1:07 am

  93. Two changes guys………

    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    set this in the surface holder and pass the holder to
    mediaplayer function
    mp.setdisplay(holder);

    it will work like magic šŸ˜‰

    Comment by deepak venugopal — January 8, 2010 @ 6:08 am

  94. Hi guys,

    I couldn’t download source code .please zip and mail it to me. ramesh_siva12@yahoo.com

    Comment by ramesh12 — January 19, 2010 @ 5:11 am

  95. Hi,
    Iā€™m unable to download videoplayer.zip, too. Could you please re-upload or send to me by email : javadianjp@yahoo.co.jp
    Thanks for all!!!

    Comment by javadian — January 28, 2010 @ 9:13 am

  96. Hi,
    Iā€™m unable to download videoplayer.zip, too. Could you please re-upload or send to me by email : kimlh2@nate.com
    Thanks for all!!!

    Comment by good guy — February 10, 2010 @ 12:19 am

  97. Hi,

    i cant download VideoPlayer.zip file
    please send me email : rully.hasibuan@ymail.com

    thx

    Comment by Rully — February 10, 2010 @ 7:31 am

  98. Hi,

    i cant download VideoPlayer.zip file
    please send me email : pmskiran@purpletalk.com

    Thanks..

    Comment by Kiran PMS — February 13, 2010 @ 10:28 am

  99. Hello! I also can’t download the VideoPlayer.zip. Kindly email it to me: sarahmae_05@yahoo.com. Thanks in advance! šŸ™‚

    Comment by sarah — February 28, 2010 @ 9:16 am

  100. Hi,
    I am unable to download this zip file.
    Can u tell corresponding another link…

    Comment by sachin — March 25, 2010 @ 8:56 am

  101. when i try to download the vidioplayer.zip then i couldn’t download it.
    can u help me.
    i u have then plz mail me @ muneshs@geniusport.com

    Comment by munesh — April 7, 2010 @ 3:58 am

  102. Look here:
    the similar code

    Comment by Valera — April 14, 2010 @ 11:31 am

  103. this code is OK but you should also explain them for naives like me.

    Comment by Vicky — May 1, 2010 @ 11:43 pm

  104. if anyone want that zip code.. write me on this id nextcome@gmail.com. I will help you on it.

    Comment by nextcome — May 6, 2010 @ 2:06 am

  105. Hello! I also canā€™t download the VideoPlayer.zip.
    Kindly email it to me: hslee@edicon.net. Thanks in advance!

    Comment by Lee HyunSoo — May 13, 2010 @ 7:37 am

  106. Great job, congratulation šŸ™‚
    Can you send me the .zip to try it ?
    Thanks a lot

    Comment by Ro — May 14, 2010 @ 3:49 am

  107. [Post New] posted Yesterday 4:09:17 PM private message
    Quote
    can anyone kindly send me android apk file for playing videos stored in sdcard with flashplayer on emulator??

    Comment by hema — June 16, 2010 @ 11:06 pm

  108. I am new to android, I want to go through code for better understanding, Can anyone send me the source code, I am not able to download it from the above link praveenbn_83@yahoo.com

    Thanks in advance….

    Comment by Praveen — June 22, 2010 @ 11:36 pm

  109. Hi, I canā€™t download the zip file from the link. Can you please send me the file to sujithcp@gmail.com Thank you in avanced!

    Comment by sujith — July 14, 2010 @ 1:43 pm

  110. Hi,
    Please reupload the source for this somewhere.
    Cheers

    Comment by Stu — July 20, 2010 @ 11:57 pm

  111. unable to play any file…it does not play the 3gp file and for some other formats it gives error…
    i have tried using landscape mode also

    Comment by chotachetan — August 23, 2010 @ 6:07 am

  112. I am new to android, I want to go through code for better understanding, Can anyone send me the source code, I am not able to download it from the above link mcrtkim@gmail.com

    Thanks in advanceā€¦.

    Comment by kim, HS — August 26, 2010 @ 9:02 am

  113. Hi.
    Please, send this zip file to me. thanks in advance.

    Comment by helen — September 9, 2010 @ 8:43 pm

  114. Hi.
    Please, send this zip file to me. thanks in advance.
    –> My email address is ‘hllim@naver.com’.

    Comment by helen — September 9, 2010 @ 8:44 pm

  115. can u sent the zip to evanhackborn@gmail.com

    Comment by evan — September 10, 2010 @ 3:06 am

  116. Hi I can’t download sourcecode.Can you please send me the file to ninechad@hotmail.com .Thank you

    Comment by ninechad — October 10, 2010 @ 1:36 am

  117. Thanks for your code
    It is working on my HTC android 1.6.
    I now can load video from the sd card.

    Thanks a lot !!!

    Comment by Sanun — October 12, 2010 @ 10:10 pm

  118. Hello, same here, could you send me the ZIP. Thanks a lot!!
    Mark

    Comment by Mark — October 14, 2010 @ 3:48 am

  119. I face this problem while running this example…
    “java.net.SocketException address family not supprted by the protocol…”

    Comment by Himanshu — November 1, 2010 @ 7:14 am

  120. Hi Please send me the zip file in my email: luther_martina@yahoo.com. Thank u!

    Comment by martina — November 17, 2010 @ 11:11 am

  121. Please send me the zip file in my email: richard.helak@gmail.com
    Thank you.

    Comment by riso — January 12, 2011 @ 4:17 pm

  122. Hi,

    Please email me the Source and APK files as the link for VideoPlayer.zip is not available.

    Thanks in advance

    Kind regards
    Mel

    Comment by Mel — May 10, 2011 @ 4:50 am

  123. Please provide me a URL of video that works, when I run this code I can hear an audio but video is not displayed.

    Comment by ankur — May 24, 2011 @ 1:47 am

  124. hi
    i am raghu working as android application developer.
    i need mediaplayer application, can u send me to my email: ambidi2raghu@gmail.com

    Comment by Raghu ambidi — June 15, 2011 @ 11:50 pm

  125. Hi Please send me the zip file to my email: tommydam1@gmail.com
    Thank you very much.

    Comment by Tommy — June 16, 2011 @ 1:36 pm

  126. Hi I canā€™t download sourcecode.Can you please send me the file to rohaneee@gmail.com .Thank you

    Comment by rohan singh — June 20, 2011 @ 8:07 am

  127. Hi,
    I cannot find the source files!, the download link is broken. Can anyone please mail to, edinettedrms@gmail.com

    Thanks

    Comment by ppk — June 27, 2011 @ 6:16 am

  128. Please send me the zip file in my email: tanuja.raavi@gmail.com
    Thank you.

    Comment by Tanuja — July 16, 2011 @ 2:23 am

  129. Can you please help me on how to store a live video into a buffer and then from buffer into a file.I am using a camera to capture the video which i want to store in a buffer and then into a file.

    Comment by pawan — August 17, 2011 @ 2:15 am

  130. Please send me the zip file in my email: koreait@paran.com
    Thank you.

    Comment by JI SEOK WOO — August 18, 2011 @ 4:59 am

  131. Hello, same here, could you send me the ZIP. Thanks a lot!!

    Comment by Gaurav — August 19, 2011 @ 2:16 am

  132. Please send me the zip file in my email: monsieur.pub@laposte.net
    Thank you

    Comment by sgo35 — August 24, 2011 @ 7:22 am

  133. Please send me the zip file in my email:vahmadtamimi62@gmail.com
    Thank you.

    Comment by Tamimi — August 24, 2011 @ 5:37 pm

  134. Please send me the zip file in my email: thanhmc1@gmail.com
    Thank you.

    Comment by kikura — August 25, 2011 @ 5:21 am

  135. Wow, there has been comments since 2007 of people asking for the code to be sent to them. Clearly, that’s not going to happen

    Comment by Fail Whale — September 4, 2011 @ 8:38 pm

  136. hello, i tried this example. The code has no error but when i run on emulator it says that application stopped unexpectedly. There is no error message on console.
    How to fix this?

    Comment by Dhruv — October 26, 2011 @ 12:55 pm

  137. hi sir ur coding is good but ur source code but not import the eclipse so how to run this source code plz tell me and how to write this code in to eclipse give me the explanation

    Comment by rambabu — October 28, 2011 @ 12:48 am

  138. hi
    i have imported d folder in my eclipse workspace….n it is working perfecly…bt d thing i want to ask is that …where should i add songs and hw to link it……as it is not playing any song…..kindly reply asap….i need it urgently…..
    thanks
    rafia

    Comment by rafia — November 1, 2011 @ 1:52 am

  139. Actually, your demo just work: download file audio (video) from network to store in local file, then play it. Can you tell me about streaming audio on android through rtsp protocol

    Comment by CTT — December 6, 2011 @ 2:52 am

  140. Please send me the zip file in my email:nagireddy454@gmail.com
    Thank you.

    Comment by Nag — December 27, 2011 @ 2:56 am

  141. Hiiiiiiiiiiii …. plz i have a problem in which i am trying to play a video file which put in NAS ftp server and when i am trying to play i am unable to play … how i can do it plz reply me its urgent ……..
    Sorry for my english
    thanks….

    Comment by Arun Yadav — January 23, 2012 @ 1:54 am

  142. I am using android sdk version 4.0.3 with eclipse sdk version 3.6.2. I am able to see the edittext box with thefile name i put in the code. I see the buttons. The file is located on the local machine. But the video does not play. All functionality and eventlistners do fire. What am I missing. Any help will be appreciated.

    Dollar

    Comment by Dollar — January 27, 2012 @ 5:21 pm

  143. The above code does not work in my case as I wana stream from ipcam using wifi router in my case
    the address is rtsp://192.168.1.155:554/3g

    Comment by EngrSofty — March 16, 2012 @ 2:21 am

  144. hi pls tell how to change next track.

    Comment by Pandian Ind — March 18, 2012 @ 12:11 pm

  145. how to play live streaming video

    Comment by lucky — May 12, 2012 @ 6:26 am

  146. […] […]

    Pingback by player andoird - Forum Android Italiano — June 27, 2012 @ 4:10 am

  147. hi
    code u write i can understand but can u give me xml file of this code so i can guess the layout of this…i m unable to run this code i want xml file……..

    Comment by mahima gupta — July 10, 2012 @ 6:14 am

  148. Hi,

    I have to download the image/Video from WCF Rest Service to AndroidApp.

    From Rest service, I am sending the Image in JSON(base64 format).
    In Android, I am not able to retrieve that JSON string.

    I am getting errors in ” JSONObject Details = new JSONObject(Tempbuffer); ”

    The errors are: “Timed out Exception” & “Unterminated character at 122449 position.”
    Note: 122449 is the Last character in JSON string

    Here is My code..

    DefaultHttpClient client = new DefaultHttpClient();
    str=tvItemName.getText().toString();

    HttpGet request = new HttpGet(DETAILS_URI + str);

    request.setHeader(“Accept”, “application/json”);
    request.setHeader(“Content-type”, “application/json”);

    //get the response
    HttpResponse response = client.execute(request);

    HttpEntity entity = response.getEntity();

    if(entity.getContentLength() != 0)
    {
    // stream reader object
    Reader DetailsReader = new InputStreamReader(response.getEntity().getContent());
    //create a buffer to fill if from reader
    char[] buffer = new char[(int) response.getEntity().getContentLength()];

    //fill the buffer by the help of reader
    DetailsReader.read(buffer);
    //close the reader streams
    DetailsReader.close();
    //String Temp2=null;

    String Tempbuffer = new String(buffer);

    JSONObject Details = new JSONObject(Tempbuffer); // —-Here I am getting Error—————

    Comment by Srinivas — September 13, 2012 @ 10:05 am

  149. Working for me! Thanks!

    Comment by ariefspekta — June 15, 2013 @ 2:36 pm


RSS feed for comments on this post. TrackBack URI

Leave a reply to Himanshu Cancel reply

Create a free website or blog at WordPress.com.