Integrating Kodi with WMC for Amazon, Netflix, etc.

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

Integrating Kodi with WMC for Amazon, Netflix, etc.

#1

Post by tonywagner » Sun Jan 28, 2018 9:59 pm

As you may have noticed, Kodi has a few great add-ons that allow you to log in with your account credentials to use internet streaming services like Amazon, Netflix, sports, etc. It's a great way to access these services with a media center PC and remote.

But because I still use WMC for TV, I went ahead and integrated access to these Kodi add-ons into the WMC menu. Here is how I did it. (This assumes you have Kodi and its addons set up as desired, let me know if you need any help with that.)
  • 1. Tell Kodi to automatically launch the desired addon when it starts. For this, we use a file called "autoexec.py" in the Kodi userdata directory ("%appdata%/Kodi/userdata"). I set up a file for each of my desired services, like the following as "autoexec-amazon.py", and just copy it to "autoexec.py" as part of my launch script later (step 5):

    Code: Select all

    import xbmc
    xbmc.executebuiltin( "ActivateWindow(Videos,plugin://plugin.video.amazon-test)" )
  • 2. Now we want to decide how to exit Kodi from our addon. By default, you would have to go back to the Kodi main menu and select the "quit" option, but that's kind of a pain. So I made my own "service addon" that detects the presence of an autoexec.py file, and then automatically quits Kodi as soon as you go back to the home screen (so basically, just by pushing the back button on your remote from the first addon screen). I've attached it as a ZIP file to this post ("service.autoexechomecloser.zip") which you can install as an addon inside Kodi.
  • 3. Now we're going to streamline the appearance. Instead of seeing the default Kodi splash screen on launch, let's replace that with a service-specific splash screen. Similar to step 1, I put a splash screen for each service, like "splash-amazon.png", in the folder "%appdata%/Kodi/media", and then as part of my launch script (step 5) we will copy it to "splash.png" before launching. I've attached my Amazon splash screen which you can use.
  • 4. Unfortunately, even with a custom splash screen, Kodi still displays its own home screen briefly during the launch process. I wanted to hide that too, which requires customizing the skin. It's pretty simple, though, to just edit an existing skin. I used the Kodi 18 default skin "Estuary" so I simply downloaded it as a ZIP file here:
    https://github.com/phil65/skin.estuary

    Then I installed that ZIP as an addon within Kodi, and it asked me if I wanted to make the new skin active, and I chose yes. Now we have access to the skin's home file, located at "%appdata%/Kodi/addons/skin.estuary/xml/Home.xml". Like steps 1 and 4, I just made a new XML file for each of my services, like "Home-amazon.xml", with the following code, and then I copy it over Home.xml in my launch script (step 5). Be sure to make a copy of the original Home.xml, to something like "Home-original.xml", which we can copy back in place when we are done, in case we want to launch Kodi with its regular home screen sometime.

    Code: Select all

    <?xml version="1.0" encoding="UTF-8"?>
    <window>
    	<controls>
    		<control type="image">
    			<aspectratio>keep</aspectratio>
    			<texture>special://home/media/splash-amazon.png</texture>
    		</control>
    	</controls>
    </window>
    You will also notice that by default Kodi puts parent directory items ("..") at the top your addon screens. You don't really need this if you are using a remote with a back button, and it can make it more difficult to get back to the home screen and activate my auto-exit addon above. But, you can easily disable this in the Kodi settings as follows: Settings -> Media -> General, deselect "Show parent folder items"
  • 5. Now it's time to make the launch script, to move the files in place from the previous steps, launch Kodi, and then remove our custom files after we quit. I make a custom script for each of my services -- here's my file "kodi-amazon.bat":

    Code: Select all

    set app=amazon
    copy C:\Users\yourusername\AppData\Roaming\Kodi\media\splash-%app%.png C:\Users\yourusername\AppData\Roaming\Kodi\media\splash.png
    copy C:\Users\yourusername\AppData\Roaming\Kodi\userdata\autoexec-%app%.py C:\Users\yourusername\AppData\Roaming\Kodi\userdata\autoexec.py
    copy C:\Users\yourusername\AppData\Roaming\Kodi\addons\skin.estuary\xml\Home-%app%.xml C:\Users\yourusername\AppData\Roaming\Kodi\addons\skin.estuary\xml\Home.xml
    "C:\Program Files\Kodi\kodi.exe"
    del C:\Users\yourusername\AppData\Roaming\Kodi\media\splash.png
    del C:\Users\yourusername\AppData\Roaming\Kodi\userdata\autoexec.py
    copy C:\Users\yourusername\AppData\Roaming\Kodi\addons\skin.estuary\xml\Home-original.xml C:\Users\yourusername\AppData\Roaming\Kodi\addons\skin.estuary\xml\Home.xml
  • 6. Lastly, you just need to launch this batch script from within WMC. A really easy way to do this is using Media Center Themer, which can add a custom menu strip to WMC. Here's what my file "%appdata%/Media Center Themer/MCTDefault.xml" looks like, with Amazon, Netflix, and even YouTube services. I've also attached the icon I used for Amazon.

    Code: Select all

    <MediaCenterThemer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MCTSchema.xsd">
    	<!-- Sample file to modify the start menu of Media Center -->
    	<StartMenu>
    		<!-- Addition of a new menu strip -->
    		<Custom Title="Streaming Services">
    			<MenuItem Name="Netflix" HideToolbar="true">
    				<Image>Theme\icon-netflix.png</Image>
    				<Program>Scripts\kodi-netflix.bat</Program>
    				<PlayingDirective>stop</PlayingDirective>
    			</MenuItem>
    			<MenuItem Name="Amazon Video" HideToolbar="true">
    				<Image>Theme\icon-amazon.png</Image>
    				<Program>Scripts\kodi-amazon.bat</Program>
    				<PlayingDirective>stop</PlayingDirective>
    			</MenuItem>
    			<MenuItem Name="YouTube" HideToolbar="true">
    				<Image>Theme\icon-youtube.png</Image>
    				<Program>Scripts\kodi-youtube.bat</Program>
    				<PlayingDirective>stop</PlayingDirective>
    			</MenuItem>
    		</Custom>
    	</StartMenu>
    </MediaCenterThemer>
    
Now you should see your new menu strip in WMC, and you can select a streaming service, and it will launch the Kodi addon, and when you are done, just hit the "back" button on your remote until you are back in WMC. I also installed "Launcher4Kodi" to automatically close Kodi on sleep, like the MCE Standby Tool, except you can disable the options to automatically open Kodi on wake (since WMC is already doing that!):
https://forum.kodi.tv/showthread.php?tid=136798

Let me know if you have any questions with this, or with general Kodi setup issues.
Attachments
service.autoexechomecloser-fixed.zip
(8.53 KiB) Downloaded 159 times
icon-amazon.png
icon-amazon.png (25.13 KiB) Viewed 7853 times
splash-amazon.png

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#2

Post by jachin99 » Mon Jan 29, 2018 12:37 am

Tony, thanks for all the hard work. Once my machines are setup right, I'll try this out.

User avatar
Crash2009

Posts: 4357
Joined: Thu May 17, 2012 12:38 am
Location: Ann Arbor, Michigan

HTPC Specs: Show details

#3

Post by Crash2009 » Wed Jan 31, 2018 3:48 am

Yes, very nice. Thank you

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#4

Post by jachin99 » Thu Feb 01, 2018 4:08 pm

To be clear guys, the Netflix input stream add-onneeds Kodi 18 and won't work with any other version. Kodi 18 is still in alpha so you have to download a nightly build. For streaming so far I have found Netflix, Spotify, and now amazon. For those who use playon tubecore for wmc still works the best for me

User avatar
DavidinCT

Posts: 1556
Joined: Mon Feb 13, 2012 3:45 pm
Location:

HTPC Specs: Show details

#5

Post by DavidinCT » Thu Feb 01, 2018 4:28 pm

Thanks for this !

This sounds like something that would be really nice. I really want a SOLID Amazon Prime app so I stream videos with out needing to switch to another device or my smart TV. Also some other apps that I might want to play with.

Do you get 5.1+ audio(bitstreaming) from Netflix and Amazon ? Or do you run into Exclusive issues (if WMC is minimized during this process.)?

And is there a easy direction to get Kodi setup ? Never set it up but, if I can get an icon in WMC for each app and can go directy into the app, and when I exit go back to WMC, I want to play with it
-Dave
Twitter @TheCoolDave

Windows Media Center certified and WMC MVP 2010 - 2012

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#6

Post by jachin99 » Thu Feb 01, 2018 4:34 pm

I have a nightly running on my PC right now, and its stable. So far I have Spotify and Netflix installed but only spotify works so I'll have to investigate netflix. One suggestion I have to build on tony's work is add event ghost for simplifying remote control setup. I use ONE remote to control my TV, WMC, and Kodi, and eventghost is the brain for all of it. Event Ghost will also simplify setup by letting users avoid setting up any xml files. My EG setup knows weather Kodi, or WMC is in focus, and enables and disables remote profiles as needed. My TV control always runs in the background.

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#7

Post by tonywagner » Thu Feb 01, 2018 7:48 pm

DavidinCT wrote:Do you get 5.1+ audio(bitstreaming) from Netflix and Amazon ? Or do you run into Exclusive issues (if WMC is minimized during this process.)?
I am no audiophile, but it appears I get 5.1 on Netflix, and only 2.0 on Amazon.

Also, both require software decoding. It is because of the DRM. So my old HTPC maxes out at 720P (which is fine by me). I am sure a better rig could handle 1080P in software. Other Kodi video add-ons (YouTube, MLB.TV, etc.) can do hardware decoding just fine.

I haven't run into any issues with WMC minimized.

User avatar
DavidinCT

Posts: 1556
Joined: Mon Feb 13, 2012 3:45 pm
Location:

HTPC Specs: Show details

#8

Post by DavidinCT » Thu Feb 01, 2018 8:27 pm

tonywagner wrote:
DavidinCT wrote:Do you get 5.1+ audio(bitstreaming) from Netflix and Amazon ? Or do you run into Exclusive issues (if WMC is minimized during this process.)?
I am no audiophile, but it appears I get 5.1 on Netflix, and only 2.0 on Amazon.

Also, both require software decoding. It is because of the DRM. So my old HTPC maxes out at 720P (which is fine by me). I am sure a better rig could handle 1080P in software. Other Kodi video add-ons (YouTube, MLB.TV, etc.) can do hardware decoding just fine.

I haven't run into any issues with WMC minimized.
Does WMC go minimized when you run this ?

With a HDMI setup with bitstreaming, only one application can have access to the bitstream (exclusive mode). So If WMC is open, and you run another app that gives 5.1 audio, you will only get stereo out of it, not even a true DD 2.0. Unchecking the "exclusive mode" in the sound settings will completely break bitstreaming in WMC. Trust me on this, I have battled with this before. Try to play a Blu-ray with PowerDVD, try to get the DTS Master HD audio from a Blu-ray when WMC is running in the background. It wont work.

I run my WMC at 4K and I use bitsreaming to give me HD audio formats, so I was interested in getting a solid 5.1 signal from Netflix and Amazon...

Anyway about it, is there a good DIY installing Kodi in the first place ?
-Dave
Twitter @TheCoolDave

Windows Media Center certified and WMC MVP 2010 - 2012

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#9

Post by tonywagner » Thu Feb 01, 2018 9:33 pm

DavidinCT wrote:And is there a easy direction to get Kodi setup ?
Here's what I did:
  • Download and install the latest Kodi 18 "Leia" nightly, I just used all the default install options:
    http://mirrors.kodi.tv/nightlies/windows/win32/master/
  • Launch Kodi. Note you can use the "\" key to toggle between windowed and fullscreen mode. At this point, you can go to "Add-ons", "Install from repository", and browse and install stuff from the default "Kodi Add-on Repository" -- stuff like YouTube, ESPN, etc.
  • If you want to try Netflix or Amazon, you will first need to enable the "Inputstream Adaptive" add-on and copy the decoder DLL file into place. Under Add-Ons, select "My Add-ons", "VideoPlayer InputStream", "InputStream Adaptive", and "Enable." You can also configure it to go up to 1080p here if you think your machine can handle software decoding at that resolution (by default it is set to 720p, which is what I have to use).
  • Now you need to get the file "widevinecdm.dll" and copy it into the folder "%appdata%/Kodi/cdm" (create the folder if it doesn't exist). You can find this file by searching a 32-bit Windows installation of Google Chrome, or it appears you can also download it from "Firefox sources" (I'll link this in a follow-up post).
  • Download Amazon and Netflix repositories:
    Netflix: https://github.com/kodinerds/repo/raw/m ... -1.0.1.zip
    Amazon: https://github.com/Sandmann79/xbmc/rele ... -1.0.2.zip
  • Back in Kodi, go to "Add-Ons", and "Install from zip file". It will probably prompt you to allow installations from unknown sources, go ahead and do that. Then navigate to the repository ZIP files you just downloaded and install them. Now go back to "Add-ons", "Install from repository", and install the Netflix video addon (under "Netflix Addon Repository") and the "Amazon VOD" video addon (under "Sandmann79s Repository").
  • Now you can launch those addons, they should prompt you to sign in, and then you can watch! You can explore Kodi keyboard/remote commands, but one I liked when I was setting up was the "o" key to display video stats.
I will say, one thing I miss is being able to resume a video where I left off. That functionality is not part of the Netflix or Amazon addons right now. But I usually watch a whole show at one time, so it's not a dealbreaker for me.

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#10

Post by tonywagner » Thu Feb 01, 2018 9:34 pm

Here's another link to download the "widevinecdm.dll" file:
https://redirector.gvt1.com/edgedl/wide ... n-ia32.zip

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#11

Post by jachin99 » Thu Feb 01, 2018 9:38 pm

David, what about having your stereo upcomvert the signal for Netflix etc. When I installed Kodi I didn't install every component, you can choose what to install and I left out the PVR and one other thing I think. There are tons of how tos out there but ask on their forums if you aren't sure. I can help more later if you need it

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#12

Post by tonywagner » Thu Feb 01, 2018 10:00 pm

DavidinCT wrote:Does WMC go minimized when you run this ?
Yes, it appears so. But that might just be a limitation of Media Center Themer. I installed the following program to add a Kodi shortcut within Media Center, and it indeed closes WMC rather than minimizes:

http://www.teknowebworks.com/Kodi-Windo ... ntegration

Looks like with some registry digging, one could customize this shortcut, or even figure out what makes it different than Media Center Themer. EDIT: Looks like the application stores its Kodi path/arguments in "HKEY_CURRENT_USER\Software\Teknowebworks, LLC\KodiIntegration", and then creates its Media Center menu item in one of the entry points under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Extensibility\Entry Points".

I also wonder if MCE Reset Toolbox would behave differently.

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#13

Post by jachin99 » Thu Feb 01, 2018 10:35 pm

Media center theme might accomplish the same thing g as kodi integration. I would have to read the documentation to be sure. I've modified Kodi integration to work with launch box before, and there is a thread around here about it. If you don't want to do all of this, you could always close wmc when Kodi opens,and relaunch it with the green button.

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#14

Post by jachin99 » Thu Feb 01, 2018 10:53 pm

Actually all that Kodi integration might do is register Kodi on the start menu via registermceapp.exe

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#15

Post by jachin99 » Fri Feb 02, 2018 3:10 am

One more question about the Amazon plugin. Can I install this from a standalone file or do I need to add some repo

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#16

Post by tonywagner » Fri Feb 02, 2018 3:30 am

jachin99 wrote:One more question about the Amazon plugin. Can I install this from a standalone file or do I need to add some repo
I have always done the repo, and the repo basically just contains the Amazon add-on. But you could download just the code from Github and install it directly, here is the download link:

https://minhaskamal.github.io/DownGit/# ... mazon-test

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#17

Post by tonywagner » Fri Feb 02, 2018 3:36 am

jachin99 wrote:If you don't want to do all of this, you could always close WMC when Kodi opens,and relaunch it with the green button.
Actually, by my method, you are already using a batch file to do stuff before launching Kodi, and again after closing Kodi.

You could probably just add a command at the beginning of the batch file to close WMC, and add another at the end to relaunch it.

Personally I like having the ability to alt-tab between Kodi and WMC. I can start playing music through my stereo in Kodi, and then switch back to WMC to watch a football game whIle the music continues to play. And I don't have to listen to the announcers. :)

jachin99

Posts: 1293
Joined: Wed Feb 24, 2016 3:36 pm
Location:

HTPC Specs: Show details

#18

Post by jachin99 » Fri Feb 02, 2018 4:20 am

I'm not too sure how to add an individual addon to kodi just yet. Can I just drop the addon code into a plugin folder somewhere in the kodi file structure? I've dealt with kodi some in the past but its been a while.

User avatar
DavidinCT

Posts: 1556
Joined: Mon Feb 13, 2012 3:45 pm
Location:

HTPC Specs: Show details

#19

Post by DavidinCT » Fri Feb 02, 2018 3:59 pm

tonywagner wrote:
DavidinCT wrote:Does WMC go minimized when you run this ?
Yes, it appears so. But that might just be a limitation of Media Center Themer. I installed the following program to add a Kodi shortcut within Media Center, and it indeed closes WMC rather than minimizes:

http://www.teknowebworks.com/Kodi-Windo ... ntegration

Looks like with some registry digging, one could customize this shortcut, or even figure out what makes it different than Media Center Themer. EDIT: Looks like the application stores its Kodi path/arguments in "HKEY_CURRENT_USER\Software\Teknowebworks, LLC\KodiIntegration", and then creates its Media Center menu item in one of the entry points under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Extensibility\Entry Points".

I also wonder if MCE Reset Toolbox would behave differently.
Could we setup each icon (Kodi program to direct run) with Relanch ? This actually closes WMC and gives a command to close the app that you are running and then restart WMC. I use it for little applications like YouTubeTV with Chrome and my Emulation Station setup. If I hit "the green button" on the remote, it closes the app completely.
-Dave
Twitter @TheCoolDave

Windows Media Center certified and WMC MVP 2010 - 2012

tonywagner

Posts: 178
Joined: Thu Feb 04, 2016 1:53 am
Location:

HTPC Specs: Show details

#20

Post by tonywagner » Fri Feb 02, 2018 4:21 pm

jachin99 wrote:I'm not too sure how to add an individual addon to kodi just yet. Can I just drop the addon code into a plugin folder somewhere in the kodi file structure? I've dealt with kodi some in the past but its been a while.
You can, but you would still have to enable it within Kodi, and it might fail if there are any dependencies. It appears that is what happens if you try to install the Amazon add-on ZIP I linked above, so it is probably not too useful. Best bet is just to install the repository and install the add-on from there, which will automatically take care of dependencies and enable the add-on.

Post Reply