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

  • Home
  • SEARCH
  • 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 3635074
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:51:31+00:00 2026-05-19T00:51:31+00:00

I’m trying to play an audio in background from a WebView. This audio is

  • 0

I’m trying to play an audio in background from a WebView. This audio is given by a URL. I approached this by overriding the url loading. And it starts playing the audio, but many times the Media Player just stops. This happens around 30% of times, and this audio files are never longer than 30 seconds.

I tried with MP3, OGG and WAV, and it happens with any of them.

I also tried but first downloading the file and then playing it, instead of stream it, but doesn’t work either.

This is a piece of code… to show you how it works:

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.endsWith(".ogg")){
        AudioLoader audioLoader = new AudioLoader(url);
        audioLoader.start();
        return true;
    }
    else if (url.endsWith(".wav")){
        Uri tempPath = Uri.parse(url);
        MediaPlayer player = MediaPlayer.create(interfazWeb, tempPath);
        if (player != null){
            player.start();
        } else {
            Log.e(TAG, "No se puede abrir el audio:" + url);
        }
        return true;
    }
    else if (url.endsWith(".mp3")){
        AudioLoader audioLoader = new AudioLoader(url);
        audioLoader.start();
        return true;
    }else{
        return super.shouldOverrideUrlLoading(view, url);
    }
}

I’ve checked the audio file saved by “AudioLoader”, and it’s totally fine. And the WAV case is using my first attemp, play it with streaming.

Also tried SoundPool and AsyncPlayer… nothing works!!

So… this far I don’t think is a communication, codec or buffer issue. My only tips are these log entries, which repeats for every time tha the problem happens, with all formats and all approaches:

12-31 09:41:49.284: WARN/AudioFlinger(59): write blocked for 160 msecs, 20 delayed writes, thread 0xd7a8
12-31 09:41:49.554: WARN/TimedEventQueue(59): Event 6 was not found in the queue, already cancelled?

Does anybody please have some clue? Or I’m just facing a bug/missfunction.

Have a happy 2011, specially if you’re able to help me 😛

Regards, Manuel.

  • 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-19T00:51:31+00:00Added an answer on May 19, 2026 at 12:51 am

    You are creating audioLoader and/or MediaPlayer objects in a local way (those objects are locals for the function shouldOverrideUrlLoading). So, once out of the function, when the garbage collector try to collect all non-referenced objects, it will destroy your objects and then the sound will stopped.

    Try declaring AudioLoader and MediaPlayer objects as global objects:

    private AudioLoader audioLoader; 
    private MediaPlayer player; 
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.endsWith(".ogg")){
                audioLoader = new AudioLoader(url);
                audioLoader.start();
                return true;
            }
            else if (url.endsWith(".wav")){
                Uri tempPath = Uri.parse(url);
                player = MediaPlayer.create(interfazWeb, tempPath);
                if (player != null){
                    player.start();
                } else {
                    Log.e(TAG, "No se puede abrir el audio:" + url);
                }
                return true;
            }
            else if (url.endsWith(".mp3")){
                audioLoader = new AudioLoader(url);
                audioLoader.start();
                return true;
            }else{
                return super.shouldOverrideUrlLoading(view, url);
            } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.