summaryrefslogtreecommitdiffstats
path: root/tests/OneMedia/src/com/android/onemedia/playback/OneMRPRenderer.java
blob: 55eb92cdb7fe1923c471ae85ab9a9aa22210b234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.android.onemedia.playback;

import android.os.Bundle;
import android.support.media.protocols.MediaPlayerProtocol;
import android.support.media.protocols.MediaPlayerProtocol.MediaInfo;

/**
 * Renderer for communicating with the OneMRP route
 */
public class OneMRPRenderer extends Renderer {
    private final MediaPlayerProtocol mProtocol;

    public OneMRPRenderer(MediaPlayerProtocol protocol) {
        super(null, null);
        mProtocol = protocol;
    }

    @Override
    public void setContent(Bundle request) {
        MediaInfo mediaInfo = new MediaInfo(request.getString(RequestUtils.EXTRA_KEY_SOURCE),
                MediaInfo.STREAM_TYPE_BUFFERED, "audio/mp3");
        mProtocol.load(mediaInfo, true, 0, null);
    }

    @Override
    public boolean onStop() {
        mProtocol.stop(null);
        return true;
    }

    @Override
    public boolean onPlay() {
        mProtocol.play(null);
        return true;
    }

    @Override
    public boolean onPause() {
        mProtocol.pause(null);
        return true;
    }

    @Override
    public long getSeekPosition() {
        return -1;
    }
}