Advertisement
Guest User

Untitled

a guest
May 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import android.widget.VideoView;
  2. APVideoView videoView;
  3. APWidgetContainer container;
  4.  
  5. void setup()
  6. {
  7. container = new APWidgetContainer(this); //create a new widget container
  8. videoView = new APVideoView(10, 50, 240, 180, false); //create a new video view, without media controller
  9. videoView.setVideoPath("/sdcard/CornFlowerFromSprout.mp4"); //specify the path to the video file
  10. container.addWidget(videoView); //place the video view in the container
  11. videoView.start(); //start playing the video
  12.  
  13. }
  14.  
  15. void draw()
  16. {
  17. background(0); //black background
  18. text(videoView.getDuration(), 10, 10); //display the length of the video in milliseconds
  19. text(videoView.getCurrentPosition(), 10, 30); //visa hur långt videon spelats
  20. }
  21. void keyPressed() {
  22. if (key == CODED) {
  23. if (keyCode == LEFT) {
  24. videoView.seekTo(0); //"rewind"
  25. }
  26. else if (keyCode == RIGHT) {
  27. videoView.start(); //start playing video file
  28. }
  29. else if (keyCode == DPAD) {
  30. videoView.pause(); //pause the playing of the video file
  31. }
  32. else if (keyCode == DOWN) {
  33. videoView.setVideoPath("sdcard/VIDEO0001.3gp"); //switch to other video file
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement