/* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.util.Objects; /** * This API is not generally intended for third party application developers. * Use the AndroidX * Media2 session * Library for consistent behavior across all devices. *
* Define a command that a {@link MediaController2} can send to a {@link MediaSession2}. *
* If {@link #getCommandCode()} isn't {@link #COMMAND_CODE_CUSTOM}), it's predefined command. * If {@link #getCommandCode()} is {@link #COMMAND_CODE_CUSTOM}), it's custom command and * {@link #getCustomAction()} shouldn't be {@code null}. *
* Refer to the
* AndroidX SessionCommand class for the list of valid commands.
*/
public final class Session2Command implements Parcelable {
/**
* Command code for the custom command which can be defined by string action in the
* {@link Session2Command}.
*/
public static final int COMMAND_CODE_CUSTOM = 0;
public static final @android.annotation.NonNull Parcelable.Creator
* Contains the result of {@link Session2Command}.
*/
public static final class Result {
private final int mResultCode;
private final Bundle mResultData;
/**
* Result code representing that the command is skipped or canceled. For an example, a seek
* command can be skipped if it is followed by another seek command.
*/
public static final int RESULT_INFO_SKIPPED = 1;
/**
* Result code representing that the command is successfully completed.
*/
public static final int RESULT_SUCCESS = 0;
/**
* Result code represents that call is ended with an unknown error.
*/
public static final int RESULT_ERROR_UNKNOWN_ERROR = -1;
/**
* Constructor of {@link Result}.
*
* @param resultCode result code
* @param resultData result data
*/
public Result(int resultCode, @Nullable Bundle resultData) {
mResultCode = resultCode;
mResultData = resultData;
}
/**
* Returns the result code.
*/
public int getResultCode() {
return mResultCode;
}
/**
* Returns the result data.
*/
@Nullable
public Bundle getResultData() {
return mResultData;
}
}
}