送经Cast.CastApi.sendMessage Chromecast的默认媒体接收器有效载荷什么 [英] What Payload to send to the Chromecast Default Media Receiver via Cast.CastApi.sendMessage

查看:342
本文介绍了送经Cast.CastApi.sendMessage Chromecast的默认媒体接收器有效载荷什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图建立从Android应用(发送方)到我的Chromecast将数据发送一个小的测试应用程序。我使用的是默认的媒体接收器,以避免支付注册,而我学习。

I have been trying to build a little test application that sends data from an android app (sender) to my chromecast. I am using the Default Media Receiver to avoid paying for registration while I learn.

所有code是在服务中实现,接收器被发现,准备好,但我不知道如何格式化负载真正得到媒体接收器做任何事情(例如显示图像)

All the code is implemented in an service, the receiver is found and ready but i don't know how to format the payload to actually get the Media Receiver to do anything (display images for example)

下面是一个有点code(如果还需要更多我很乐意将它张贴)。该onConnected()方法被调用,并没有错误运行,接收器连接,并准备好,表现出的Chromecast符号但是画面,其中我送的URL不显示。

Here is a bit of code (if more is needed I gladly post it). The onConnected() method is called and runs without errors, the receiver is connected and ready, showing the chromecast symbol but the picture of which I send the URL is not shown.

private class ConnectionCallbacks implements GoogleApiClient.ConnectionCallbacks
{

    @Override
    public void onConnected(Bundle bundle)
    {

        Log.d(TAG, "on connected for callback");
 Cast.CastApi.launchApplication(mApiClient,
                CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID, false)
                .setResultCallback(new ResultCallback<Cast.ApplicationConnectionResult>()
                {
                    @Override
                    public void onResult(Cast.ApplicationConnectionResult result)
                    {
                        Log.d(TAG, "OnResultCallback... ");
                        Status status = result.getStatus();
                        Log.d(TAG, "ApplicationConnectionResultCallback.onResult: statusCode" + status.getStatusCode());
                        if (status.isSuccess())
                        {
                            mApplicationStarted=true;
                            ApplicationMetadata applicationMetadata = result.getApplicationMetadata();
                            mSessionId = result.getSessionId();
                            String applicationStatus = result.getApplicationStatus();
                            boolean wasLaunched = result.getWasLaunched();
                            Log.d(TAG, mSessionId+" "+applicationStatus);
                            try
                            {
                                Cast.CastApi.sendMessage(mApiClient, "urn:x-cast:com.google.cast.media",
                                        "http://www.randomwebsite.com/images/head.jpg")
                                        .setResultCallback(new ResultCallback<Status>()
                                        {
                                            @Override
                                            public void onResult(Status result)
                                            {
                                                if (!result.isSuccess())
                                                {
                                                    Log.e(TAG, "Sending message failed");
                                                }
                                            }
                                        });
                            }
                            catch(Exception e)
                            {
                                Log.e(TAG, "Sending message to chromecast failed... hard.");
                            }
                        }
                    }
                });
    }

    @Override
    public void onConnectionSuspended(int i)
    {
        Log.d(TAG, "on connection suspended for callback");
    }
}

这与大多数$ C $的c是类似于 https://github.com/googlecast从谷歌/ CastHelloText-的Andr​​oid 的例子。

This and most of the code is similar to the https://github.com/googlecast/CastHelloText-android example from google.

我的问题,我认为是行 Cast.CastApi.sendMessage(mApiClient,瓮:X-投:com.google.cast.media,HTTP://www.randomwebsite。 COM /图像/ head.jpg)尤其是我刚才怀疑第三个参数未格式化默认的媒体接收器预计数据的方式。但是我找不到有这方面的工作的例子。

My problem, I think is the line Cast.CastApi.sendMessage(mApiClient, "urn:x-cast:com.google.cast.media", "http://www.randomwebsite.com/images/head.jpg") especially the third parameter which i suspect just isn't formatted the way the Default Media Receiver expects data. However I could not find any working examples on this.

那么,一个人如何使用默认的媒体接收器来运行得到一个工作的例子?

So, how does one get a working example using the Default Media Receiver to run?

推荐答案

如果你想给你自己的信息(非媒体),你应该创建自己的名称空间的自定义接收器。默认接收器/接收器乐府既懂媒体命名空间和使用该命名空间,不使用的sendMessage;使用RemoteMediaPlayer发送像普通的动作播​​放/暂停/停止/搜索/ ......还有我们的GitHub库一些样品。

If you want to send you own messages (non-media), you should create a custom receiver with your own namespace. The Default Receiver/Styled Receiver only understands media namespace and to use that namespace, do not use sendMessage; use RemoteMediaPlayer to send common actions like play/pause/stop/seek/... There are some samples on our GitHub repo.

这篇关于送经Cast.CastApi.sendMessage Chromecast的默认媒体接收器有效载荷什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆