blob: c21edd345cefc5fe975147e4d23f6442f8d29612 [file] [log] [blame]
Justin Klaassenb8042fc2018-04-15 00:41:15 -04001/*
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.annotation.TargetApi;
20import android.app.PendingIntent;
21import android.content.Context;
22import android.os.Build;
23import android.support.v4.media.session.MediaSessionCompat;
24
25import androidx.annotation.NonNull;
26import androidx.media.MediaLibraryService2.MediaLibrarySession;
27
28import java.util.concurrent.Executor;
29
30@TargetApi(Build.VERSION_CODES.KITKAT)
31class MediaLibrarySessionImplBase extends MediaSession2ImplBase {
32 MediaLibrarySessionImplBase(Context context,
33 MediaSessionCompat sessionCompat, String id,
34 MediaPlayerBase player, MediaPlaylistAgent playlistAgent,
35 VolumeProviderCompat volumeProvider, PendingIntent sessionActivity,
36 Executor callbackExecutor,
37 MediaSession2.SessionCallback callback) {
38 super(context, sessionCompat, id, player, playlistAgent, volumeProvider, sessionActivity,
39 callbackExecutor, callback);
40 }
41
42 static final class Builder extends MediaSession2ImplBase.BuilderBase<
43 MediaLibrarySession, MediaLibrarySession.MediaLibrarySessionCallback> {
44 Builder(Context context) {
45 super(context);
46 }
47
48 @Override
49 public @NonNull MediaLibrarySession build() {
50 if (mCallbackExecutor == null) {
51 mCallbackExecutor = new MainHandlerExecutor(mContext);
52 }
53 if (mCallback == null) {
54 mCallback = new MediaLibrarySession.MediaLibrarySessionCallback() {};
55 }
56 return new MediaLibrarySession(new MediaLibrarySessionImplBase(mContext,
57 new MediaSessionCompat(mContext, mId), mId, mPlayer, mPlaylistAgent,
58 mVolumeProvider, mSessionActivity, mCallbackExecutor, mCallback));
59 }
60 }
61}