1/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package androidx.media;
18
19import android.os.Bundle;
20
21import androidx.annotation.Nullable;
22
23import java.util.List;
24
25class MediaInterface2 {
26    private MediaInterface2() {
27    }
28
29    // TODO: relocate methods among different interfaces and classes.
30    interface SessionPlaybackControl {
31        void prepare();
32        void play();
33        void pause();
34        void reset();
35
36        void seekTo(long pos);
37
38        int getPlayerState();
39        long getCurrentPosition();
40        long getDuration();
41
42        long getBufferedPosition();
43        int getBufferingState();
44
45        float getPlaybackSpeed();
46        void setPlaybackSpeed(float speed);
47    }
48
49    interface SessionPlaylistControl {
50        void setOnDataSourceMissingHelper(MediaSession2.OnDataSourceMissingHelper helper);
51        void clearOnDataSourceMissingHelper();
52
53        List<MediaItem2> getPlaylist();
54        MediaMetadata2 getPlaylistMetadata();
55        void setPlaylist(List<MediaItem2> list, MediaMetadata2 metadata);
56        void updatePlaylistMetadata(MediaMetadata2 metadata);
57
58        MediaItem2 getCurrentMediaItem();
59        void skipToPlaylistItem(MediaItem2 item);
60        void skipToPreviousItem();
61        void skipToNextItem();
62
63        void addPlaylistItem(int index, MediaItem2 item);
64        void removePlaylistItem(MediaItem2 item);
65        void replacePlaylistItem(int index, MediaItem2 item);
66
67        int getRepeatMode();
68        void setRepeatMode(int repeatMode);
69        int getShuffleMode();
70        void setShuffleMode(int shuffleMode);
71    }
72
73    // Common interface for session2 and controller2
74    // TODO: consider to add fastForward, rewind.
75    abstract static class SessionPlayer implements SessionPlaybackControl, SessionPlaylistControl {
76        abstract void skipForward();
77        abstract void skipBackward();
78        abstract void notifyError(@MediaSession2.ErrorCode int errorCode, @Nullable Bundle extras);
79    }
80}
81