Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod inside Thread is going out of focus
    primarykey
    data
    text
    <p>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,</p> <pre><code> public void start() { try { if (start == 0) { playpause.setBackgroundDrawable(getResources().getDrawable( R.drawable.play)); initialPoiPlayStatus = true; playAudio(); } if (play) { if (mMediaPlayer != null &amp;&amp; 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(); } } </code></pre> <p>Now inside youtube,</p> <pre><code> 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; } </code></pre> <p>Here whenever, if (convSeconds == youTubeStartTime) {} becomes true, I am making my audio pause i.e., </p> <pre><code> if (mMediaPlayer.isPlaying()) { mMediaPlayer.pause(); } </code></pre> <p>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 </p> <pre><code>if (!mMediaPlayer.isPlaying()) { mMediaPlayer.start(); } </code></pre> <p>Audio keeps playing now, but the slider/seekbar is not moving because start() inside notification is not getting called. </p> <p>Do any one know why is it happening like this?</p> <p><strong>Note</strong>: 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</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload