Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:40:16+00:00 2026-05-29T04:40:16+00:00

is there something wrong with the code? Some reason it won’t be played? import

  • 0

is there something wrong with the code? Some reason it won’t be played?

import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.MotionEvent;
import android.widget.VideoView;

public class Video extends Activity implements OnCompletionListener, OnPreparedListener {

        static private final String pathToFile ="com.chich.res.drawable-  hdpi.troopers.3gp";  // Video source file
       private VideoView videoPlayer;

       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.video);


      videoPlayer = (VideoView) findViewById(R.id.videoPlayer);   
      videoPlayer.setOnPreparedListener(this);
      videoPlayer.setOnCompletionListener(this);
      videoPlayer.setKeepScreenOn(true);    
      videoPlayer.setVideoPath(pathToFile);
       }


       /** This callback will be invoked when the file is ready to play */
       @Override
       public void onPrepared(MediaPlayer vp) {


          if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
          videoPlayer.start();
        }

        /** This callback will be invoked when the file is finished playing */
        @Override
        public void onCompletion(MediaPlayer  mp) {
          // Statements to be executed when the video finishes.
          this.finish();    
        }

        /**  Use screen touches to toggle the video between playing and paused. */
        @Override
        public boolean onTouchEvent (MotionEvent ev){   
           if(ev.getAction() == MotionEvent.ACTION_DOWN){
              if(videoPlayer.isPlaying()){
                       videoPlayer.pause();
              } else {
                       videoPlayer.start();
              }
              return true;      
           } else {
               return false;
           }
        }
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:40:17+00:00Added an answer on May 29, 2026 at 4:40 am

    I don’t think setVideoPath will work if your video is part of your apps resources. Use a URI: Referring to Android resources using URIs. There’s an example of using the VideoView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's something wrong with my code or I'm just not understanding this fully. I
I might be doing something completely wrong here but for some reason the values
Are methods calls really so slow or is there something wrong in my computer?
There is something wrong with this trigger. But what? CREATE TRIGGER MYCOOLTRIGGER AFTER INSERT
I wonder if there is something wrong with the copy constructor function below? class
After quite some time debugging my code, I tracked down the reason for my
The below code works, but for some reason the $('#chart').fadeTo callback seems to create
Is there something like the Python descriptor protocol implemented in other languages? It seems
Is there something special about Safari for Windows and AJAX? In other words: Are
Is there something like InstallShield that I can use for free?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.