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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:20:24+00:00 2026-05-27T03:20:24+00:00

I have a method which I am calling from onCreate( main thread). Inside the

  • 0

I have a method which I am calling from onCreate( main thread). Inside the method I am calling one more method and a Runnable that calls the same method repeatedly. This is how it looks,

 public void start() {
    try {
        if (start == 0) {
            playpause.setBackgroundDrawable(getResources().getDrawable(
                    R.drawable.play));
            initialPoiPlayStatus = true;
            playAudio();
        }
        if (play) {
            if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
                // for displaying view stub
                poi = listOfPOI.get(j);
                int pos = mMediaPlayer.getCurrentPosition();
                int convSeconds = -1;
                convSeconds = ((int) (pos) / 1000);
                // displaying the you tube pop up based on the parsed value
                // from the plist
                youTube(convSeconds);
                // call the method to change the image while the audio is
                // playing
                changeImage();
                seek_bar.setProgress(current_position);
                notification = new Runnable() {
                    public void run() {
                        start();
                    }
                };
                handler.postDelayed(notification, 1000);
            } else {
                if (j != (listOfPOI.size() - 1)) {
                    firstPlay = true;
                    initialPoiPlayStatus = true;
                    j++;
                    playAudio();
                    start();
                    // retrieve mascot info
                    if (isNetworkAvailable() == true) {
                        receiveResponse();
                    } else {

                    }
                } else {
                    threadHandler.sendEmptyMessage(0);
                }
            }
        }
    } catch (Exception e) {
        System.out.println(poi.getPlistPath());
        e.printStackTrace();
    }
}

Now inside youtube,

 private void youTube(int convSeconds) {
    frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
    youtubeWebView = (WebView) findViewById(R.id.youtubewebView);
    try {
        if (poi.getIsYoutubePresent().equals("true")) {

            //mMediaPlayer.pause();
            isNetworkAvailable();
            if (isNetworkAvailable() == true) {

                String startTimeyoutube = poi.getYoutubestartTime();
                Integer youTubeStartTime = Integer
                        .parseInt(startTimeyoutube);
                if (convSeconds == youTubeStartTime) {

                    if (frameLayout.getVisibility() == View.GONE) {
                        frameLayout.setVisibility(View.VISIBLE);
                        slideUp = AnimationUtils.loadAnimation(this,
                                R.anim.slide_up);
                        frameLayout.startAnimation(slideUp);
                    }

                    final String youTubeurl = poi.getLink();
                    WebSettings websets = youtubeWebView.getSettings();
                    websets.setJavaScriptEnabled(true);
                    registerForContextMenu(youtubeWebView);
                    youtubeWebView
                            .setWebViewClient(new ItemsWebViewClient());
                    youtubeWebView.loadUrl(youTubeurl);
                    youtubeWebView.getSettings().setLayoutAlgorithm(
                            LayoutAlgorithm.SINGLE_COLUMN);
                    firstPlay = false;
                    initialPoiPlayStatus = false;
                    paused = true;
                    play = false;
                    playpause.setBackgroundDrawable(getResources().getDrawable(
                            R.drawable.play));
                    if (mMediaPlayer.isPlaying()) {
                        mMediaPlayer.pause(); 
                    }

                    Button goBtn = (Button) findViewById(R.id.youtubeButton);
                    goBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View V) {
                            startActivity(new Intent(Intent.ACTION_VIEW,
                                    Uri.parse(youTubeurl)));
                        }
                    });

                    ImageButton close = (ImageButton) findViewById(R.id.youtubecloseButton);
                    close.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View arg0) {
                            frameLayout.setVisibility(View.GONE);
                            if (!mMediaPlayer.isPlaying()) {
                                mMediaPlayer.start();
                            }
                                    playpause.setBackgroundDrawable(getResources().getDrawable(
                                    R.drawable.pause));
                        }
                    });
                } 
            } else {
                Toast.makeText(getApplicationContext(), "No network available", Toast.LENGTH_SHORT).show();
            }
        } else {
            frameLayout.setVisibility(View.INVISIBLE);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return;
}

Here whenever, if (convSeconds == youTubeStartTime) {} becomes true, I am making my audio pause i.e.,

 if (mMediaPlayer.isPlaying()) {
    mMediaPlayer.pause(); 
}

And during this time also I want the start() inside Runnable notification should be keep calling. But if I make audio pause this is not happening only. The control is completely lost in this case. And on pressing the Image button close, i am trying to make the audio again to play like this

if (!mMediaPlayer.isPlaying()) {
    mMediaPlayer.start();
}

Audio keeps playing now, but the slider/seekbar is not moving because start() inside notification is not getting called.

Do any one know why is it happening like this?

Note: How ever if I don make my mediaplayer not to pause, it works fine. I get the problem onky when I make the audio to pause

  • 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-27T03:20:24+00:00Added an answer on May 27, 2026 at 3:20 am

    I solved the issue finally, it may not be the standard way. But it is working for me.

    i just replicated

               notification = new Runnable() {
    
                    public void run() {
                        start();
                    }
                };
                handler.postDelayed(notification, 1000); 
    

    where I am trying to close the image button, i.e.,

      ImageButton close = (ImageButton) findViewById(R.id.youtubecloseButton);
                    close.setOnClickListener(new OnClickListener() {
    
                        @Override
                        public void onClick(View arg0) {
                            frameLayout.setVisibility(View.GONE);
                            if (!mMediaPlayer.isPlaying()) {
                                mMediaPlayer.start();
                            }
               notification = new Runnable() {
    
                    public void run() {
                        start();
                    }
                };
                handler.postDelayed(notification, 1000); 
                        }
                    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method which is called from both QThreads and the main thread.
I have the following method, I have one more method through which I am
I am facing an issue where I have one method which is calling another
I have a GridView which I am populating by calling a method to return
I have a view with which I have a button calling the following method.
I have a method which should be delayed from running for a specified amount
I have a method which constructs an object, calls an Execute method, and frees
I have the following method which is used to populate a DAO from the
I have a PHP class method which is using a static function from with
I just discovered that when calling Java from Matlab object.method(arg1,...,argn) is equivalent to method(object,

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.