gpt4 book ai didi

android - remoteMediaPlayer.requestStatus(...) 返回 statusCode SIGN_IN_REQUIRED

转载 作者:搜寻专家 更新时间:2023-11-01 07:59:06 25 4
gpt4 key购买 nike

我有一个广播应用程序可以在 Google Chromecast 上播放现场广播电台。使用 remoteMediaPlayer.load(...) 启动流就可以了。但是 remoteMediaPlayer.requestStatus(...) 稍后停止流时说 statusCode=SIGN_IN_REQUIRED 并抛出 IllegalStateException: No current media session/p>

为什么我不能停止播放直播广播流?或者如何停止 remoteMediaPlayer 播放?

实时广播流是 HTTP。这可能是问题所在吗?

这里是详细信息:

以下代码启动流并正常工作。

    MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
mediaMetadata.putString(MediaMetadata.KEY_TITLE, stationName);
mediaMetadata.addImage(new WebImage(Uri.parse(imageUrl)));
final MediaInfo mediaInfo = new MediaInfo.Builder(stationUrl).setContentType("audio/mp3").setStreamType(MediaInfo.STREAM_TYPE_LIVE)
.setMetadata(mediaMetadata).build();
try {
mRemoteMediaPlayer.load(apiClient, mediaInfo, true).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (result.getStatus().isSuccess()) {
Utils.log(TAG, "Media loaded successfully: " + result.getStatus());
} else {
Utils.log(TAG, "Media loaded NOT successfully: " + result.getStatus());
}
}
});
} catch .... {

以下代码停止流并且它不起作用。结果是 statusCode=SIGN_IN_REQUIREDjava.lang.IllegalStateException: No current media session

public static void stop() {
try {
mRemoteMediaPlayer.requestStatus(apiClient).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {

@Override
public void onResult(RemoteMediaPlayer.MediaChannelResult mediaChannelResult) {
Status status = mediaChannelResult.getStatus();
Utils.log(TAG, "RemoteMediaPlayer requestStatus: Status=" + status.getStatus());
try {
mRemoteMediaPlayer.stop(apiClient);
} catch (Exception e) {
Log.e(TAG, "Exception while stopping GoogleApiClient. ", e);
}
}
});
} catch (IllegalStateException e) {
Log.e(TAG, "Problem occurred while geting requestStatus", e);
} catch (Exception e) {
Log.e(TAG, "Exception while geting requestStatus. ", e);
}
}

日志:

05-25 06:19:58.360: D/CastHelper(30561): RemoteMediaPlayer requestStatus: Status=Status{statusCode=SIGN_IN_REQUIRED, resolution=null}
05-25 06:19:58.360: E/CastHelper(30561): Exception while stopping GoogleApiClient.
05-25 06:19:58.360: E/CastHelper(30561): java.lang.IllegalStateException: No current media session
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.internal.es.dC(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.internal.es.b(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.cast.RemoteMediaPlayer$4.a(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.cast.RemoteMediaPlayer$4.a(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.common.api.a$b.b(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.common.api.b.a(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.common.api.b.b(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.cast.RemoteMediaPlayer.stop(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.cast.RemoteMediaPlayer.stop(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.mydomain.myapp.CastHelper$8.onResult(CastHelper.java:97)
05-25 06:19:58.360: E/CastHelper(30561): at com.mydomain.myapp.CastHelper$8.onResult(CastHelper.java:1)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.common.api.a$c.b(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at com.google.android.gms.common.api.a$c.handleMessage(Unknown Source)
05-25 06:19:58.360: E/CastHelper(30561): at android.os.Handler.dispatchMessage(Handler.java:102)
05-25 06:19:58.360: E/CastHelper(30561): at android.os.Looper.loop(Looper.java:136)
05-25 06:19:58.360: E/CastHelper(30561): at android.app.ActivityThread.main(ActivityThread.java:5579)
05-25 06:19:58.360: E/CastHelper(30561): at java.lang.reflect.Method.invokeNative(Native Method)
05-25 06:19:58.360: E/CastHelper(30561): at java.lang.reflect.Method.invoke(Method.java:515)
05-25 06:19:58.360: E/CastHelper(30561): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
05-25 06:19:58.360: E/CastHelper(30561): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
05-25 06:19:58.360: E/CastHelper(30561): at dalvik.system.NativeStart.main(Native Method)

最佳答案

toString() 并不是获取状态代码的好方法。 RemoteMediaPlayer 有自己的一组 STATUS_* 代码。 SIGN_IN_REQUIRED 为 4,即 RemoteMediaPlayer.STATUS_REPLACED 表示您发出了另一个与此请求相同类型的请求。根据设计,RemoteMediaPlayer 只会跟踪每种类型的一个请求。例如,如果您在第一个 PAUSE 请求完成之前发送一个 PAUSE 后跟另一个 PAUSE(即,收到来自接收方的回复),它将停止跟踪第一个 PAUSE 并报告此错误。

关于android - remoteMediaPlayer.requestStatus(...) 返回 statusCode SIGN_IN_REQUIRED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23853777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com