APWidgets Sound but No Video

edited March 2016 in Android Mode

Hi, I've been trying to get the default video (for APWIDGETS) example up and running https://code.google.com/p/apwidgets/wiki/APVideoViewExample. I've activated all the permissions and the path to the file has been set correctly; however, when I run the example all I get is a black screen with the numbers for the length of the video, no image is displayed but the sound does play. I've tried this example on 2 different devices (a phone and a tablet) and the problem persists.

I have tried several video archives, .mp4, .webm, and .3gp. Any help with this will be greatly appreciated.


  • @javosanc=== you are happy to get sound... i have tried & left (once i saw something, a very little video, 360/120) nut only once....Since, i used the android media player and a videoView and everything works well! - As for formats, 3gp and .mp4 are the most compatibles, see here : [http://developer.android.com/guide/appendix/media-formats.html]

  • @akenaton how do you use the android media player and videoView in a sketch, can you provide an example? thank you very much for replying!

  • edited May 2015

    @javosanc you have to import

    ---import android.widget.VideoView; import android.media.MediaPlayer; basically::: create instance for them (eg= mVideo = new VideoView()..) set the size of your videoview == mVideo.setMinimumWidth,same for height choose the video uri and assign it to your videoview call on prepare() or prepareAsync for mPlayer then call the start() method with your videoview dont forget to release the mPlayer in onResume() you can also add a mediacontroller

    ps you can find all methods here https://developer.android.com/reference/android/widget/VideoView.html

  • I was able to get APVideoViewExample to work on my Nexus 7 running 4.4.2, a few months ago. The only non-obvious thing I had to do was enable WRITE_EXTERNAL_STORAGE, even though it seemed to have nothing to do with playing a video file.

  • @billhsu I'm using 4.1.2 on my phone; I forgot what the tablet is using. In any case, the weird thing is that the sound plays, so it means that the file has been located and at least partially loaded.

  • @akenaton So I have this:

    ` import android.widget.VideoView; import android.media.MediaPlayer;

    VideoView mVideo; MediaPlayer mPlayer;

    void setup() { mVideo = new VideoView(this); mPlayer = new MediaPlayer(); mVideo.setMinimumWidth(500); mVideo.setMinimumHeight(200); mVideo.setVideoPath("/storage/sdcard0/DCIM/Camera/VID_20150315_200329.3gp"); mVideo.setOnPreparedListener(mPlayer); mVideo.start(); }

    void draw() {

    } `

    However, the compiler throws an error saying that the way I'm initializing the setOnPrepared is wrong. That's the only one I couldn't understand how to use. Maybe I'm making a noobish mistake here... :(

  • @javosanc:::

    yes, compiler is wright, try this (perhaps you have also to add try catch statements before mvideo.setVideoPath()....

                            MediaPlayer.OnPreparedListener()  {
                                 public void onPrepared(MediaPlayer mp) {
                  //you can add code here                      
  • @akenaton I got the following error: FATAL EXCEPTION: Animation Thread java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    So I guess this doesn't work on the standard setup() and draw() structure of Processing and that I have to use Eclipse instead? sorry for bothering you so much, and thanks a lot for your help!

  • @javosanc:: Right, & as for me i used eclipse for android, not processing; yet it seems to me that i have got this error once, working with processing + eclipse and found some work around (creating some handler???) - i have to look at this and will give you the solution as soon as possible.

  • @javosanc== excuse me for answering: i am very busy... Finally i had a look to your problem and found 2 or 3 solutions; best one (the more simple) is this one; i have written this code in eclipse but using processing (integrated) so i am sure that you can easily use it into processsing. as for me it works. PS: i have choosen to play video from url, but you can also change easily for sd card.

        import processing.core.PApplet;// of course in eclipse!!!!
        import android.media.MediaPlayer;
        import android.media.MediaPlayer.OnPreparedListener;
        import android.net.Uri; 
        import android.os.Looper;
        import android.app.Activity;
        import android.widget.LinearLayout;
        import android.widget.MediaController; //if you want to add //mediacontroller
        import android.widget.VideoView;
        import android.content.Context;
        public class MainActivity extends PApplet {
            public final String videoURL = "http://www.androidbegin.com/tutorial/AndroidCommercial.3gp";
            Context c;
            VideoView vv;
            MediaPlayer mp;
            MediaController mc;
            Uri ladresse;// or the path to your internal file
            PApplet pApplet;
            public void setup(){
                Looper.prepare();//see your error message
                vv = new VideoView(this);
                mp = new MediaPlayer();
                        MediaPlayer.OnPreparedListener()  {
                    public void onPrepared(MediaPlayer mp) {
                        System.out.println("je suis ok");
                creeVideo();// this does the job!
            public void draw(){
            public void creeVideo(){
                final Activity activity = (Activity) this;
                activity.runOnUiThread(new Runnable(){
                    public void run(){
                        VideoView vv = new VideoView(activity);
                        ladresse = Uri.parse(videoURL);
  • @javosanc:: & dont forget to add internet permission if you use my code...

Sign In or Register to comment.