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 9203399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:27:55+00:00 2026-06-17T23:27:55+00:00

package z.x; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import android.app.Activity; import android.content.Context;

  • 0
package z.x;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

public class AsdqweActivity extends Activity {
    /** Called when the activity is first created. */
    VideoView myVideoView;
    TextView translation;
    String SrcPath = "/sdcard/bunny.MP4",txtdisplay="";
    Thread Thread1,Thread2;
    Button tag;
    int count=0,tstart=-1,tend=0;
    AudioManager am;
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        myVideoView = (VideoView) findViewById(R.id.newVideoView);
        translation= (TextView) findViewById(R.id.translation);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(myVideoView);
        myVideoView.setMediaController(mediaController);
        myVideoView.setKeepScreenOn(true);
        Runnable runnable = new VideoPlayer();
        Thread2= new Thread(runnable);   
        Thread2.start();

        runnable = new CountDownRunner();
        Thread1= new Thread(runnable);   
        Thread1.start();

        runnable = new AudioPlayer();
        Thread1= new Thread(runnable);   
        Thread1.start();

        am = 

        tag = (Button) findViewById(R.id.start);
        tag.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                //how to change the text on the button????????
                if(count%2==0)
                {
                    tstart=myVideoView.getCurrentPosition();
                    System.out.println("tag starts here: "+ tstart);
                    myVideoView.pause();
                    tend=tstart+1000;
                    count++;
                    if((tstart+1000)>myVideoView.getDuration())
                    {
                        tend=myVideoView.getDuration();
                        count++;
                    }
                }
                else
                {
                    tend = myVideoView.getCurrentPosition();
                    if(tend>=(tstart+1000)){
                        System.out.println("tag ends here: "+ tend);
                        count++;
                        myVideoView.pause();    
                    }
                    else
                    {
                        System.out.println("invalid tagging");
                    }
                    tstart=-1;
                }
            }
        });
        myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() 
        {
            public void onCompletion(MediaPlayer mp) 
            {
            Log.v("log_tag", "On Completion");
            try {
                Thread1.join();
                Thread2.join();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            //r.stopThread();
            finish();
            }
        });
    }

    class VideoPlayer implements Runnable{

        public void run()
        {
            myVideoView.requestFocus();
            myVideoView.setVideoPath(SrcPath);
            myVideoView.start();
        }

    }

    class AudioPlayer implements Runnable{

        public AudioPlayer() {
            // TODO Auto-generated constructor stub

        }
        public void run()
        {
            /*myVideoView.setsetvolume(0,0);
            audio.requestFocus();
            audio.setVideoPath(SrcPathaudio);
            audio.start();*/
        }

    }

    class CountDownRunner implements Runnable
    {   
        File file = new File("/sdcard/harsh.srt");
        long r=0;
        RandomAccessFile rand;
        public CountDownRunner() {
            // TODO Auto-generated constructor stub
            if(!file.exists())
            {
              System.out.println("File does not exist.");
              System.exit(0);
            }
            try {
                rand = new RandomAccessFile(file,"r");
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            translation = (TextView)findViewById(R.id.translation);

        }
        public void run() 
        {   
            // Get the object of DataInputStream
            while(!Thread.currentThread().isInterrupted())
            {
                try 
                {
                    doWork();
                    Thread.sleep(100);
                }catch (InterruptedException e) 
                {
                    Thread.currentThread().interrupt();
                    e.printStackTrace();
                }catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            closeRandFile();

        }
        public void closeRandFile(){
            try {
                rand.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public void doWork(){
            runOnUiThread(new Runnable() {
                public void run() {
                    try{
                        rand.seek(r);
                        //If it returns  milliseconds, divide by 1000
                        int playTime = myVideoView.getCurrentPosition();
                        long t1=0,t2=0;
                        int i=0,j=0;
                       /* String textValue = "i havent entered it yet";
                        System.out.println(playTime);
                        if(playTime<15000){
                        textValue = "its still not 15000";
                        System.out.println(textValue);
                        }else if(playTime>3000)
                        {textValue = "its more than 15000";}*/
                        ////////////////////////////////////
                        try{
                          // Open the file that is the first 
                          // command line parameter

                          String strLine;
                          //Read File Line By Line
                          while(((strLine = rand.readLine()) != null)&&((strLine=="")))
                          {
                              System.out.println(strLine+"  line 184");
                          }
                          if(strLine != null)
                          {
                              i = Integer.parseInt(strLine);
                              System.out.println(strLine+"  line 189");
                              if(i>j){
                                  if((strLine = rand.readLine()) != null)
                                  {
                                      //02:03:24,100 --> 02:03:25,500
                                      //String substring(int startIndex, int endIndex)
                                      int h =Integer.parseInt(strLine.substring(0,2));
                                      int m =Integer.parseInt(strLine.substring(3,5));
                                      int s =Integer.parseInt(strLine.substring(6,8));
                                      int ms=Integer.parseInt(strLine.substring(9,12));
                                      t1 = (((((h*60)+m)*60)+s)*1000)+ms ;
                                      System.out.println("start of this text time "+t1);
                                      int l = strLine.indexOf("-->")+4;
                                      h =Integer.parseInt(strLine.substring(l+0,l+2));
                                      m =Integer.parseInt(strLine.substring(l+3,l+5));
                                      s =Integer.parseInt(strLine.substring(l+6,l+8));
                                      ms=Integer.parseInt(strLine.substring(l+9,l+12));
                                      t2 = (((((h*60)+m)*60)+s)*1000)+ms ;
                                      System.out.println("end of this text time "+t2);
                                  }
                                  if((playTime<=t2)&&(playTime>=t1)){
                                        while (((strLine = rand.readLine()) != null)&&(strLine!="")){
                                              // Print the content on the console
                                                  txtdisplay=txtdisplay+strLine;    
                                          }
                                          System.out.println(txtdisplay);
                                          r=rand.getFilePointer(); 
                                          translation.setText(txtdisplay);
                                  }
                                  txtdisplay="";
                          }
                          }
                          //Close the input stream

                            }catch (Exception e){//Catch exception if any
                          System.err.println("Error: " + e.getMessage());
                          }
                        //////////////////////////////////////  
                    }catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

        }
    }
}

I am new here. I was asked by my professor to play other audio while the same video is being played(for example a person doesn’t understand English and wants the the app to play french ). I have used video view. One possible method was to mute the present audio and play the french audio stored in my sdcard. but video view supports no muting( i couldn’t find one). I read that i have to go for media player instead of video view.
Please help…!! what should i do… Thanks in advance.

  • 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-06-17T23:27:56+00:00Added an answer on June 17, 2026 at 11:27 pm

    if you want to get access to the MediaPlayer of a VideoView you have to call MediaPlayer.OnPreparedListener and MediaPlayer.OnCompletionListener, then you can call setVolume(0f, 0f); function to set the volume to 0.

    Do this:

    @Override
    
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_video);
    
      VideoView videoView = (VideoView)this.findViewById(R.id.VVSimpleVideo);
      MediaController mc = new MediaController(this);
      mc.setAnchorView(videoView);
      mc.setMediaPlayer(videoView);
      videoView.setMediaController(mc);
      String _path = "/mnt/sdcard/Movies/video5.mp4";
    
      videoView.setVideoPath(_path);
      videoView.setOnPreparedListener(PreparedListener);
    
      videoView.requestFocus();
    
      //Dont start your video here
      //videoView.start();
    
    
    }
    
    MediaPlayer.OnPreparedListener PreparedListener = new MediaPlayer.OnPreparedListener(){
    
         @Override
         public void onPrepared(MediaPlayer m) {
             try {
                    if (m.isPlaying()) {
                        m.stop();
                        m.release();
                        m = new MediaPlayer();
                    }
                    m.setVolume(0f, 0f);
                    m.setLooping(false);
                    m.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }    
         }
     };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the class Db.java package calc.three; import java.io.IOException; import android.app.Activity; import android.app.ListActivity; import
Here is my code: package com.commonsware.android.skeleton; import android.app.Activity; import android.content.Context; import android.hardware.Camera; import android.hardware.Camera.*;
package tutorial; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import com.hp.hpl.jena.ontology.OntModel;
package com.commonsware.android.layouts; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.Date; public class
package com.test.methods; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException;
package mp1practice; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level;
package com.csl.bps.util; import java.awt.Event; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.HashMap;
package mp1similar; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer;
package mp1similar; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer;
Here's the class package db; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import

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.