前言
我有自己的播放器拥有自己的原生音频引擎。最近我决定为它添加强制转换功能。要#'流'音频到自定义演员应用程序我决定使用WebSocket
并在其上发送float32 PCM,然后通过WebAudio API
播放。由于自定义音频格式,我决定编写自己的cast.receiver.media.Player实现sample.MyPlayer
问题
我在play
上致电pause
或com.google.android.gms.cast.RemoteMediaPlayer
后
java.lang.IllegalStateException:没有当前的媒体会话
在打电话之前我当然会com.google.android.gms.cast.RemoteMediaPlayer.load
和有趣的时刻。由于某种原因,sample.MyPlayer
没有收到mediaSessionId
看起来这与java方面的异常有关。但我在js方面的sample.MyPlayer.load
叫。
我的应用程序的日志片段
的日志片段cast_receiver.js:61 [21.034s] [cast.receiver.MediaManager]加载消息 收到:{" requestId":2," media":{...}," autoplay":false," currentTime":0 }
cast_receiver.js:61 [30.243s] [cast.receiver.MediaManager]加载收到的消息:{" type":" LOAD"," requestId" :2," mediaSessionId":0," customData":null," media":{...}," autoplay":true " currentTime的":0}
正如您所看到的,我的自定义接收器中的有效负载缺少mediaSessionId
,type
,customData
键
这就是我发现的一个问题。
我的player.html
<!DOCTYPE html>
<html>
<head>
<title>Cast Reference Receiver</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="player.css" />
<script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js"></script>
<script type="text/javascript" src="player.js"></script>
</head>
<body style="margin: 0">
<div id="player" class="player">
<div class="logo"></div>
<div class="spinner"></div>
<div class="watermark"></div>
<div class="gradient"></div>
<div class="overlay">
<div class="media-info">
<div class="media-artwork"></div>
<div class="media-text">
<div class="media-title"></div>
<div class="media-subtitle"></div>
</div>
</div>
<div class="preview-mode-info">
<div class="preview-mode-artwork"></div>
<div class="preview-mode-text">
<div class="preview-mode-timer">
<div class="preview-mode-timer-starts">Up next in </div>
<div class="preview-mode-timer-countdown"></div>
<div class="preview-mode-timer-sec"> secs...</div>
</div>
<div class="preview-mode-title"></div>
<div class="preview-mode-subtitle"></div>
</div>
</div>
<div class="controls">
<span class="controls-play-pause"></span>
<span class="controls-cur-time"></span>
<span class="controls-total-time"></span>
<div class="controls-progress">
<div class="controls-progress-inner progressBar"></div>
<div class="controls-progress-thumb"></div>
</div>
</div>
</div>
</div>
<script>
var mediaManager_ = new cast.receiver.MediaManager(new sample.MyPlayer(), [
cast.receiver.media.Command.LOAD,
cast.receiver.media.Command.PLAY,
cast.receiver.media.Command.STOP,
cast.receiver.media.Command.GET_STATUS,
cast.receiver.media.Command.PAUSE,
cast.receiver.media.Command.STREAM_VOLUME,
cast.receiver.media.Command.QUEUE_NEXT,
cast.receiver.media.Command.QUEUE_PREV
]);
var receiverManager = cast.receiver.CastReceiverManager.getInstance();
receiverManager.start();
</script>
</body>
</html>
问题
java.lang.IllegalStateException: No current media session
?