Commit b6b84839 by olly Committed by Oliver Woodman

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
parent 55d1abaa
...@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.Player; ...@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.util.ErrorMessageProvider;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -294,17 +295,6 @@ public final class MediaSessionConnector { ...@@ -294,17 +295,6 @@ public final class MediaSessionConnector {
} }
/** /**
* 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}. * The wrapped {@link MediaSessionCompat}.
*/ */
public final MediaSessionCompat mediaSession; public final MediaSessionCompat mediaSession;
...@@ -320,7 +310,7 @@ public final class MediaSessionConnector { ...@@ -320,7 +310,7 @@ public final class MediaSessionConnector {
private CustomActionProvider[] customActionProviders; private CustomActionProvider[] customActionProviders;
private int currentWindowIndex; private int currentWindowIndex;
private Map<String, CustomActionProvider> customActionMap; private Map<String, CustomActionProvider> customActionMap;
private ErrorMessageProvider errorMessageProvider; private ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider;
private PlaybackPreparer playbackPreparer; private PlaybackPreparer playbackPreparer;
private QueueNavigator queueNavigator; private QueueNavigator queueNavigator;
private QueueEditor queueEditor; private QueueEditor queueEditor;
...@@ -411,7 +401,8 @@ public final class MediaSessionConnector { ...@@ -411,7 +401,8 @@ public final class MediaSessionConnector {
* *
* @param errorMessageProvider The error message provider. * @param errorMessageProvider The error message provider.
*/ */
public void setErrorMessageProvider(ErrorMessageProvider errorMessageProvider) { public void setErrorMessageProvider(
ErrorMessageProvider<? super ExoPlaybackException> errorMessageProvider) {
this.errorMessageProvider = errorMessageProvider; this.errorMessageProvider = errorMessageProvider;
} }
......
/*
* 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment