在我正在开发的应用程序中,我想支持 Netfilx 流媒体。我打算通过简单地启动 Netflix 并传递一个特定的 URI 来做到这一点,以便它在启动时播放特定的视频。简单吧?好吧,问题是我不确定如何在用于启动 Activity 的 Intent 中传递视频 ID 信息。
我已阅读帖子 here ,但不确定在哪里使用它。我使用了 Intent.setData() 因为它接受 URI,但无济于事。
这是我一直在做的(我正在硬编码电影数据,这只是为了测试目的):
// the Netflix intent
Intent intent = getPackageManager().getLaunchIntentForPackage("com.netflix.mediaclient");
//the uri
Uri uri = Uri.parse("http://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
intent.setData(uri);
//launches but does not go to the video
startActivity(intent);
我也试过在上面的链接中使用 URI 协议(protocol),如下所示:
Uri uri = Uri.parse("nflx://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");
但我仍然没有看到视频播放。
我觉得我在这里遗漏了一些简单的东西,尽管我在谷歌上搜索时运气不佳,但我几乎找不到关于从另一个应用程序启动 Netflix Android 应用程序的任何内容。 Netflix 开发人员资源没有这方面的任何信息。
有没有人对我如何执行此操作或我应该在哪里寻找相关文档有任何建议?任何帮助,将不胜感激。非常感谢!
最佳答案
我已经成功做到了。使用以下代码。首先,您需要 netflix 的 movieId(或 videoId),然后编写要观看的 URL。
String netFlixId = "43598743"; // <== isn't a real movie id
String watchUrl = "http://www.netflix.com/watch/"+netFlixId;
然后有了这个 Intent
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.launch.UIWebViewActivity");
intent.setData(Uri.parse(watchUrl));
startActivity(intent);
}
catch(Exception e)
{
// netflix app isn't installed, send to website.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(item.url));
startActivity(intent);
}
我还没有尝试过电视节目。但这效果很好。如果你想发送到电影的个人资料页面..将它发送到这样格式的 url
http://www.netflix.com/title/324982
我还了解了如何搜索标题。
try {
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setClassName("com.netflix.mediaclient", "com.netflix.mediaclient.ui.search.SearchActivity");
intent.putExtra("query", item.label);
startActivity(intent);
}
catch(Exception e)
{
Toast.makeText(this, "Please install the NetFlix App!", Toast.LENGTH_SHORT).show();
}
关于android - 启动 Android Netflix 应用程序并传递视频 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18217559/