Add ErrorMessageProvider to util package
It's needed in multiple places. MediaSessionConnector uses it today. Our leanback connector will also use it. Maybe SimpleExoPlayerView should use one too, to show the message to the user when an error occurs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164720020
This commit is contained in:
parent
55d1abaa21
commit
b6b84839ed
@ -38,6 +38,7 @@ import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.Timeline;
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||
import com.google.android.exoplayer2.util.ErrorMessageProvider;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -293,17 +294,6 @@ public final class MediaSessionConnector {
|
||||
PlaybackStateCompat.CustomAction getCustomAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an exception into an error code and a user readable error message.
|
||||
*/
|
||||
public interface ErrorMessageProvider {
|
||||
/**
|
||||
* Returns a pair consisting of an error code and a user readable error message for a given
|
||||
* exception.
|
||||
*/
|
||||
Pair<Integer, String> getErrorMessage(ExoPlaybackException playbackException);
|
||||
}
|
||||
|
||||
/**
|
||||
* The wrapped {@link MediaSessionCompat}.
|
||||
*/
|
||||
@ -320,7 +310,7 @@ public final class MediaSessionConnector {
|
||||
private CustomActionProvider[] customActionProviders;
|
||||
private int currentWindowIndex;
|
||||
private Map<String, CustomActionProvider> customActionMap;
|
||||
private ErrorMessageProvider errorMessageProvider;
|
||||
private ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
|
||||
private PlaybackPreparer playbackPreparer;
|
||||
private QueueNavigator queueNavigator;
|
||||
private QueueEditor queueEditor;
|
||||
@ -411,7 +401,8 @@ public final class MediaSessionConnector {
|
||||
*
|
||||
* @param errorMessageProvider The error message provider.
|
||||
*/
|
||||
public void setErrorMessageProvider(ErrorMessageProvider errorMessageProvider) {
|
||||
public void setErrorMessageProvider(
|
||||
ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider) {
|
||||
this.errorMessageProvider = errorMessageProvider;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 com.google.android.exoplayer2.util;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
/**
|
||||
* Converts exceptions into error codes and user readable error messages.
|
||||
*/
|
||||
public interface ErrorMessageProvider<T extends Exception> {
|
||||
|
||||
/**
|
||||
* Returns a pair consisting of an error code and a user readable error message for the given
|
||||
* exception.
|
||||
*
|
||||
* @param exception The exception for which an error code and message should be generated.
|
||||
*/
|
||||
Pair<Integer, String> getErrorMessage(T exception);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user