android-media-controller示例代码崩溃

时间:2018-06-28 16:20:01

标签: android android-mediasession

我试图了解此代码示例的工作方式:React/Redux links list

问题是尝试实例化MediaBrowserCompat时崩溃。 这是我在logcat中看到的错误:  E / MediaBrowser:ComponentInfo {com.audible.application / com.audible.application.car.PremiumMediaBrowserService}的onConnectFailed

它与Spotify完美配合。

任何理论?

我还没有修改上面链接中的示例代码。这是我正在谈论的部分:

    private void setupMedia() {
    // Should now have a viable details.. connect to browser and service as needed.
    if (mMediaAppDetails.componentName != null) {
        mBrowser = new MediaBrowserCompat(this, mMediaAppDetails.componentName,
                new MediaBrowserCompat.ConnectionCallback() {
                    @Override
                    public void onConnected() {
                        setupMediaController();
                        mBrowseMediaItemsAdapter.setRoot(mBrowser.getRoot());
                    }
                    @Override
                    public void onConnectionSuspended(){
                        //TODO(rasekh): shut down browser.
                        mBrowseMediaItemsAdapter.setRoot(null);
                    }
                    @Override
                    public void onConnectionFailed() {

                        showToastAndFinish(getString(
                                R.string.connection_failed_msg, mMediaAppDetails.appName));
                    }

                }, null);
        mBrowser.connect();
    } else if (mMediaAppDetails.sessionToken != null) {
        setupMediaController();
    } else {
        showToastAndFinish(getString(R.string.connection_failed_msg, mMediaAppDetails.appName));
    }
}

0 个答案:

没有答案