Movie Deeplink for Netflix Android TV app (com.netflix.ninja)

孤者浪人 提交于 2019-12-05 07:20:41

问题


I have seen solutions on how to do movie deeplinking for Netflix for the mobile Netflix app, but for the Android TV version of the app those same solutions don't seem to be working.

I have tried using an Intent with action.VIEW and passing the normal Netflix URL such as: http://www.netflix.com/watch/{movieId} or with the nflx:// protocol.

For the android TV app only the nflx:// protocol seems to do anything where it opens the app and then it just stays at the main menu instead of playing the movie. Using the http:// protocol opens to netflix in the browser where it just asks you to download the phone or tablet app.

Has anyone been able to figure this out?


回答1:


Netflix recently added universal search support to Android TV, which means there had to be some way to deep link to shows and movies. So I found a few flags you need to set to correctly open the show page. It seems like there are also extras which could be used to automatically start playing.

public void OpenNFX() {
    Intent netflix = new Intent();
    netflix.setAction(Intent.ACTION_VIEW);
    netflix.setData(Uri.parse("http://www.netflix.com/watch/70291117"));
    netflix.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
    getActivity().startActivity(netflix);
}



回答2:


I wanted the same, so I spent some time digging. It had to be possible because Netflix series and movies show up in the Android TV launcher search results and can be launched from there. Apparently there are intent extras in that intent and they are the missing piece. The biggest problem was that there is no easy way to capture those intent extras (logcat doesn't show the extras), still I found a way. The following code does what you want:

Intent netflix = new Intent();
netflix.setAction(Intent.ACTION_VIEW);
netflix.setData(Uri.parse("http://www.netflix.com/watch/70202141"));
netflix.putExtra("source","30"); // careful: String, not int
netflix.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
getActivity().startActivity(netflix);

Alternatively, through adb:

adb shell am start -c android.intent.category.LEANBACK_LAUNCHER -a android.intent.action.VIEW -d http://www.netflix.com/watch/70202141 -f 0x10808000 -e source 30 com.netflix.ninja/.MainActivity

This way I can launch right into a movie or series and it automatically starts playing. To launch into the screen without automatic playback, use /title/ instead of /watch/. Tested on netflix ninja 3.3.1 build 1513 for Android TV on arm.



来源:https://stackoverflow.com/questions/35556634/movie-deeplink-for-netflix-android-tv-app-com-netflix-ninja

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!