8000 PlayerHater · cqr/PlayerHater Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Rebecca Nesson edited this page May 1, 2013 · 2 revision 73DA s

#Welcome to the PlayerHater wiki!

PlayerHater is a library for playing longform audio, such as music or podcasts, on Android. It provides a simple interface for your Fragments and Activities to start and monitor playback. There's also a plugin system if you need to do anything fancy.

PlayerHater works by adding a Service to your application's manifest and then automatically starting the service as needed. When your application enters the background, PlayerHater will continue to run if there's something loaded into it. Conversely, if you don't load anything into it, it will never even start.

It also acts as a sort of shim for the new pieces of functionality added to Android over the past several years dealing with media playback. PlayerHater ships with 5 plugins that are selectively loaded by default depending on the version of Android that your application is running on.

That means that PlayerHater will work all the way back to version 1.5, but that phones and devices with support for lock screen controls, expandable notifications, and the audio focus APIs introduced in 2.2 will still get the best functionality available.

Here's an example of how you might use PlayerHater:

package com.example.playerhatertest;

import android.app.Activity;
import org.prx.android.playerhater.PlayerHater;

public class MainActivity extends Activity implements OnClickListener {

    private BoundPlayerHater mPlayerHater;
    private Button mButton;

    // ...

    @Override
    public void onResume() {
        super.onResume();
        mButton.setOnClickListener(this);
        mPlayerHater = PlayerHater.bind(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        mPlayerHater.release();
    }

    @Override
    public void onClick(View view) {
        if (mPlayerHater.isPlaying()) {
            mPlayerHater.pause();
        } else {
            mPlayerHater.play(new Uri("http://example.com/test.mp3"));
        }
    }
}
Clone this wiki locally
0