Loading...
Logo
Processing Forum

Video playback on Android

in Android Processing  •  7 months ago  
Hi,
I'm trying to play a video file in a processing sketch on an Android tablet. I'm using APWidgets since it's the only suitable library I found for the purpose. When the sketch starts the audio plays fine but the screen is black.

Does anyone know how to solve this, or are there other libraries I can use?

Thanks!

Daniele 

Replies(5)

I post the code - it won't be that useful, I guess...

Copy code
  1. import apwidgets.*; 

  2. APVideoView videoView; 
  3. APWidgetContainer container; 

  4. void setup()
  5. {
  6.         container = new APWidgetContainer(this); //create a new widget container
  7.         videoView = new APVideoView(10, 50, 1200, 780, false); //create a new video view, without media controller
  8.         videoView.setVideoPath("/sdcard/Prova.mp4"); //specify the path to the video file
  9.         container.addWidget(videoView); //place the video view in the container
  10.         videoView.start(); //start playing the video
  11.         videoView.setLooping(true); //restart the video when the end of the file is reached

  12. }

  13. void draw()
  14. {
  15.   background(255); //black background
  16.   text(videoView.getDuration(), 10, 10); //display the length of the video in milliseconds
  17.   text(videoView.getCurrentPosition(), 10, 30); //visa hur långt videon spelats 
  18. }
I have the same problem on my Galaxy tablet and apwidgets. I've been using the updated ketai library to capture live video, so it may be a place to look for playback as well.
hi  fenicento...
I tried to play the video on my android device with help of your program. 
 i successfully upload the movie program on my device but when i play the  program on my device it shows me "can't play this video". Video is in Sdcard memory and name is also correct. 
Thanking you in anticipation

hi Ja_Ha, try this without upload files on your device,  (activate internet permissions), (it works for me)



Copy code

  1. import apwidgets.*;

    APVideoView videoView;
    APWidgetContainer container;

    void setup()
    {
            container = new APWidgetContainer(this); //create a new widget container
            videoView = new APVideoView(10, 50, 1200, 780, false); //create a new video view, without media controller
            videoView.setVideoPath("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); //specify the path to the video file
            container.addWidget(videoView); //place the video view in the container
            videoView.start(); //start playing the video
            videoView.setLooping(true); //restart the video when the end of the file is reached

    }

    void draw()
    {
      background(255); //black background
      text(videoView.getDuration(), 10, 10); //display the length of the video in milliseconds
      text(videoView.getCurrentPosition(), 10, 30); //visa hur långt videon spelats
    }



Hi   julienrat...
Thank you for your reply.
I tried your code but the result is same "sorry this video cannot be played".
I prefer to do this with video's present in SDcard because in the end i need to control videos by accelrometer.
requesting response
thanking you in anticipation