启动Android的Netflix应用,并通过视频ID [英] Launching Android Netflix App And Passing Video Id

查看:346
本文介绍了启动Android的Netflix应用,并通过视频ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用我的工作我想支持Netfilx流。我打算通过简单地启动Netflix和传递一个特定的URI所以它起着特定的视频开始时这样做。简单吧?那么,问题是我不知道如何通过在我使用的启动活动的意图视频ID信息。

我在这里阅读后,但我不确定在哪里使用。我用Intent.setData(),因为它接受一个URI,但无济于事。

下面是我一直在做什么(我硬编码的影像数据,这只是用于测试):

  // Netflix的意图
意图意图= getPackageManager()getLaunchIntentForPackage(com.netflix.mediaclient);
//的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);
//发布但还没有到视频
startActivity(意向);

我也使用URI协议上面,像这样的链接尝试

 乌里URI = Uri.parse(\"nflx://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755\");

但我仍然没有看到视频播放。

我觉得我在这里简单的东西,虽然我有非常一点运气谷歌搜索对于这一点,我可以找到从另一个应用程序启动Netflix的Andr​​oid应用微乎其微。 Netflix的开发人员资源没有任何这信息。

有谁会对我怎么能做到这一点有任何建议或我应该在哪里寻找这个文件?任何帮助将是AP preciated。谢谢了!


解决方案

我已经成功地做​​到这一点。用下面的code。首先,你需要在Netflix的movieId(或VIDEOID),然后撰写的URL来观看。

 字符串netFlixId =43598743; //< ==是不是一个真正的电影ID
字符串watchUrl =htt​​p://www.netflix.com/watch/\"+netFlixId;

然后用这个意图

  {尝试
        意向意图=新意图(Intent.ACTION_VIEW);
        intent.setClassName(com.netflix.mediaclient,com.netflix.mediaclient.ui.launch.UIWebViewActivity);
        intent.setData(Uri.parse(watchUrl));
        startActivity(意向);
}
赶上(例外五)
{
        // Netflix的应用程序没有安装,发送到网站。
        意向意图=新意图(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(item.url));
        startActivity(意向);
}

我还没有尝试过的电视节目呢。但是,这精美的作品。如果您想发送到个人资料页的电影..它发送给格式化这样一个网址

  http://www.netflix.com/title/324982

我也发现了如何搜索标题

  {尝试
        意向意图=新意图(Intent.ACTION_SEARCH);
        intent.setClassName(com.netflix.mediaclient,com.netflix.mediaclient.ui.search.SearchActivity);
        intent.putExtra(查询,item.label);
        startActivity(意向);    }
    赶上(例外五)
    {
        Toast.makeText(这一点,请安装Netflix应用!,Toast.LENGTH_SHORT).show();    }

In the app I am working on I want to support Netfilx streaming. I intend on doing this by simply starting Netflix and passing a specific URI so it plays a specific video when started. Simple right? Well, the issue is I'm not sure how to pass the video id info in the Intent I use to start the Activity.

I've read the post here , but am unsure where to use this. I used Intent.setData() since it accepts a URI, but to no avail.

Here is what I have been doing (I am hard coding the movie data, this is just for testing purposes) :

// 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);

I've also tried using the URI protocol in the link above like so:

Uri uri = Uri.parse("nflx://movies.netflix.com/WiPlayer?movieid=70266228&trkid=13462049&ctx=0%2C1%2Ce2bd7b74-6743-4d5e-864f-1cc2568ba0da-61921755");

but still am not seeing the video play.

I feel like I am missing something simple here, although I have had very little luck Googling for this, I could find next to nothing about starting the Netflix Android app from another application. The Netflix developer resources don't have any info on this.

Does anyone have any suggestions on how I can do this or where I should be looking for documentation on this? Any help would be appreciated. Thanks much!

解决方案

I've managed to do this. With the following code. First you need the movieId (or videoId) for netflix, then compose the URL to watch.

String netFlixId = "43598743"; // <== isn't a real movie id
String watchUrl = "http://www.netflix.com/watch/"+netFlixId;

Then with this 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);
}

I haven't tried with TV Shows yet. But this works beautifully. If you want to send to the profile page of the movie.. Send it to a url formatted this way

http://www.netflix.com/title/324982

I also found out how to search for a title.

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的Netflix应用,并通过视频ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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