Launching Android Netflix App And Passing Video Id

前端 未结 3 1186
闹比i
闹比i 2021-02-06 12:00

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 st

3条回答
  •  自闭症患者
    2021-02-06 12:19

    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();
    
        }
    

提交回复
热议问题