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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:27:28+00:00 2026-06-06T05:27:28+00:00

I am streaming a radio Stream. I want to generate a notification when the

  • 0

I am streaming a radio Stream. I want to generate a notification when the song in the stream changes. I am using streamscraper (http://code.google.com/p/streamscraper) to get the metadata of the current stream, and I try to generate a notification when the metadata changes.

Here is the Async Task that I created to implement this.

public class updateMetadata extends
        AsyncTask<String, Void, PlaylistSong<BaseArtist, BaseAlbum>> {

    private static final String TAG = updateMetadata.class.getSimpleName();
    private PlaylistSong<BaseArtist, BaseAlbum> oldSong = null;
    private PlaylistSong<BaseArtist, BaseAlbum> newSong = null;
    private metadataHarvester fetchMetadata = new metadataHarvester();
    private String streamUrl = null;

    @Override
    protected PlaylistSong<BaseArtist, BaseAlbum> doInBackground(String... urls) {
        for (String url : urls) {
            try {
                oldSong = fetchMetadata.prepareRadioSong(url);
            } catch (Exception e) {
                e.printStackTrace();
            }
            streamUrl = url;
        }

        newSong = oldSong;

        while (newSong == oldSong) {
            try {
                newSong = fetchMetadata.prepareRadioSong(streamUrl);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return newSong;
    }

    @Override
    protected void onPostExecute(PlaylistSong<BaseArtist, BaseAlbum> song) {
        Log.v(TAG, "New Song: " + song.getTitle());
    }
}

The application is built on two linked projects. Project A is where the Application is initialised and Project B contains the collections and the playing logic. I want to use this task in Project B. Here is the play function (in project B).

protected synchronized void play(final IMediaPlayerWrapper mp) {

        streamURL = streamFetcher.getStreamUrl();
        Log.i(TAG, "Stream URL: " + streamURL);
        try {
            Log.i(TAG, "Testing metadata harvester");
            radioSong = metadata.prepareRadioSong(streamURL);
        } catch (Exception e) {
            Log.w(TAG, e);
        }
        updateMetadata(radioSong);
        currentPlaylistManager.clearPlaylist();
        currentPlaylistManager.appendSongAtEnd(radioSong);
        listenerInformer.informCurrentSongChangeListener(radioSong);
        try {
            mp.setSong(radioSong, streamURL);
            mp.play();
            if (mp.isPlaying()) {
                setPlayerState(PlayerState.PLAY);
            }
        } catch (Exception e) {
            Log.w(TAG, e);
            setPlayerState(PlayerState.ERROR);
        }


        updateMetadata metadataChecker = new updateMetadata();
        metadataChecker.execute(streamURL);
    }

When I try to execute it, the application crashes.

Here, is the complete error trace:

04-04 23:34:34.975: E/WindowManager(18080): Activity ch.ethz.dcg.pancho2.view.radioplayer.RadioPlayerActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4053e8f0 that was originally added here
04-04 23:34:34.975: E/WindowManager(18080): android.view.WindowLeaked: Activity ch.ethz.dcg.pancho2.view.radioplayer.RadioPlayerActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4053e8f0 that was originally added here
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.ViewRoot.<init>(ViewRoot.java:258)
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
04-04 23:34:34.975: E/WindowManager(18080):     at android.app.Dialog.show(Dialog.java:241)
04-04 23:34:34.975: E/WindowManager(18080):     at android.app.ProgressDialog.show(ProgressDialog.java:107)
04-04 23:34:34.975: E/WindowManager(18080):     at android.app.ProgressDialog.show(ProgressDialog.java:90)
04-04 23:34:34.975: E/WindowManager(18080):     at ch.ethz.dcg.pancho2.view.radioplayer.RadioPlayerActivity$5.onClick(RadioPlayerActivity.java:276)
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.View.performClick(View.java:2485)
04-04 23:34:34.975: E/WindowManager(18080):     at android.view.View$PerformClick.run(View.java:9080)
04-04 23:34:34.975: E/WindowManager(18080):     at android.os.Handler.handleCallback(Handler.java:587)
04-04 23:34:34.975: E/WindowManager(18080):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-04 23:34:34.975: E/WindowManager(18080):     at android.os.Looper.loop(Looper.java:130)
04-04 23:34:34.975: E/WindowManager(18080):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-04 23:34:34.975: E/WindowManager(18080):     at java.lang.reflect.Method.invokeNative(Native Method)
04-04 23:34:34.975: E/WindowManager(18080):     at java.lang.reflect.Method.invoke(Method.java:507)
04-04 23:34:34.975: E/WindowManager(18080):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-04 23:34:34.975: E/WindowManager(18080):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-04 23:34:34.975: E/WindowManager(18080):     at dalvik.system.NativeStart.main(Native Method)

I am confused in my understanding of Async Tasks. Is this not the correct way to use them?

EDIT: Answer added separately.

  • 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-06T05:27:30+00:00Added an answer on June 6, 2026 at 5:27 am

    Solved using TimerTask.

    private void pollMetadata() {
    
        lastSong = radioSong;
        newSong = lastSong;
        Log.i(TAG, "Old Song: " + lastSong.getTitle());
        Log.i(TAG, "New Song: " + newSong.getTitle());
    
        updateMetadataTask = new TimerTask() {
    
            @Override
            public void run() {
                try {
                    newSong = metadata.prepareRadioSong(streamURL);
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                Log.i(TAG, "Old Song: " + lastSong.getTitle());
                Log.i(TAG, "New Song: " + newSong.getTitle());
    
                if (newSong.getTitle().equals(lastSong.getTitle())) {
                    Log.v(TAG, "SAME SONG");
                }
                else {
                    Log.v(TAG, "SONG CHANGED");
                    lastSong = newSong;
    
                    currentPlaylistManager.clearPlaylist();
                    currentPlaylistManager.appendSongAtEnd(newSong);
                    listenerInformer.informCurrentSongChangeListener(newSong);
    
                }
    
            }
        };
    
        t.schedule(updateMetadataTask, 300, 30000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote an streaming app and want an notification if the stream is playing.
Background: I'm streaming radio using double buffering approach for html shoutcast. I get metadata
Looking to stream a radio station on my website, we also host the streaming
How can i do the live http radio stream on android and Blackberry? I
I am streaming online radio from url using MediaPlayer. Is there any way to
HI all, My app is able to play radio streaming. But now, i want
I´m currently building a web radio streaming app using the BackgroundAudioPlayer. The problem is
I wrote a streaming radio app that is fairly basic in functionality but some
I've created a simply web radio streaming app, and on of my app user
I have to create app that provides online radio streaming (icecast), preferably .ogg format.

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.