Difference between revisions of "Netflix Streaming LIRC Integration"

From MythTV Official Wiki
Jump to: navigation, search
(Mythnetflix scripts)
(Mythnetflix scripts)
Line 118: Line 118:
 
#mythnetflix.sh -- this is the master script try to avoid editing this
 
#mythnetflix.sh -- this is the master script try to avoid editing this
 
#mythnetflix-start-before-firefox.sh -- this script will run commands before Firefox starts. I have it reset some of the LIRC settings
 
#mythnetflix-start-before-firefox.sh -- this script will run commands before Firefox starts. I have it reset some of the LIRC settings
#mythnetflix-start-after-firefox.sh -- this script will run commands while Firefox is running. I have it center the mouse on the Netflix profile selector. I also included a simple hack to fix some window focus issues I've had but it is shipped disabled. See more about the weird wm behavior hack (not written yet)
+
#mythnetflix-start-after-firefox.sh -- this script will run commands while Firefox is running. I have it center the mouse on the Netflix profile selector. I also included a simple hack to fix some window focus issues I've had but it is shipped disabled. See more about the weird [[WM_Behavior_Hack]] (not written yet)
 
#mythnetflix-stop.sh -- this script will run commands after firefox has closed. I have it set some LIRC settings back, edit this if you have done some customizing of LIRC using irxec or irxevent. I also included my wm behavior hack but it is disabled.
 
#mythnetflix-stop.sh -- this script will run commands after firefox has closed. I have it set some LIRC settings back, edit this if you have done some customizing of LIRC using irxec or irxevent. I also included my wm behavior hack but it is disabled.
  

Revision as of 00:41, 24 April 2014

This is a set of scripts and custom LIRC file to decently integrated Netflix with Mythfrontend on a Mythtv system. Right now I only have a LIRC file which work with Netflix on a 1920X1080 screen, you can use it with other resolutions but only some key will work right. For proper placement of Netflix buttons and for the scripts to work you MUST follow my Firefox setup instructions, and you MUST set the panel to auto hide. Or you can edit the scripts as you see fit.

The scripts will only work right if there is no other instances of Firefox running at the same time.

All of these steps must be performed as the same user that runs Mythfrontend

These are instruction for a Mythbuntu 12.04 install. I did get it to also work just fine on an Xubuntu 14.04 install with 1 small edit which I will address later.

first thing, access the desktop by either exiting out of Mythfrontend completely or hitting Ctrl-Alt-Right Arrow

Install Extra Software

  1. lirc-x -- provides irxevent
  2. xdotool
  3. xautomation -- provides xte

sudo apt-get install lirc-x xdotool xautomation

Panel

Set the panel to autohide.

  1. Right click on the Panel
  2. Scroll down to "Panel" and over to "Panel Preferences"
  3. Check "Automatically show and hide the panel"
  4. Click "Close"

You can get the Panel to Raise again by pushing the mouse to the top of the screen

Firefox

Quick instructions

Install the Pipelight plugin and enable Sliverlight. (directions for enabling are lower on install instructions page)

Create and Customize Firefox "mythtv-netflix" profile

Firefox Customization options

  1. Home page = http://www.netflix.com
  2. User Agent Overrider add- on installed and set to Windows/Firefox
  3. Hide Menu Bar and Navigation Toolbar
  4. Full Screen

The Long Instructions

Install Pipelight/Silverlight

  1. The first thing you need to do is install the Pipelight plugin and enable Sliverlight (directions for enabling are lower on install instructions page)
  2. Start Firefox and wait for the Pipelight/Silverlight plugin to install
  3. Go to the test page to make sure Pipelight/Silverlight plugin is working
  4. Close Firefox

Customize Firefox with a mythtv-netflix profile

  1. Open a Terminal
  2. type firefox -p
  3. a window will pop up
  4. Click on "Create Profile"
  5. Click "Next"
  6. Enter the profile name "mythtv-netflix" without quotes
  7. Click "Finish"
  8. You should return to the "Choose User Profile Window"
  9. There should now be a "mythtv-netflix" proflie
  10. Click "Exit"

You have now created a mythtv-netflix profile in Firefox, this profile will be customized and is used by the scripts to run Netflix from Mythfrontend

Customize mythtv-netflix profile:

  1. enter firefox -p mythtv-netflix in the terminal
  2. Maximize the Firefox window with the Maximize button
  3. Do the key combo CTRL-SHIFT-A
  4. in the "Search all add-ons" box, type User Agent Overrider
  5. Install the "User Agent Overrider" add-on
  6. Close the add-ons tab
  7. Set User Agent Overrider to Windows/Firefox
  8. Firefoxsetup1 gms.jpg
  9. Go to Netlix and login with "Remember Me" checked
  10. You should now be on the Netflix main screen
  11. Go to the Menu Bar
  12. Click on "Edit" and "Preferences"
  13. In they box next to "Home Page:" type http://www.netflix.com
  14. Click on "Close"
  15. Go to the Menu Bar
  16. Click on "View" go to "Toolbars" click on "Navigation Toolbar"
  17. Go to the Menu Bar
  18. Click on "View" go to "Toolbars" click on "Menu Bar"
  19. Your Firefox should now look like this taking up the whole screen. Take note if the close window button is on the left or the right.

Firefoxfinal gms.jpg

Close Firefox, you are done customizing it!

Mythnetflix scripts

Make a "mythnetflix" directory in your /home/'user' directory

mkdir ~/mythnetflix

Download the mythnetflix.zip file. for now you can download it from my personal site from the same howto page Mythtv Netflix Hack

Extract it and place all 5 files in your mythnetflix directory.

  1. mythnetflix.sh
  2. mythnetflix1080.lircrc
  3. mythnetflix-start-after-firefox.sh
  4. mythnetflix-start-before-firefox.sh
  5. mythnetflix-stop.sh


Make scripts executable:

chmod +x ~/mythnetflix/mythnetflix.sh ~/mythnetflix/mythnetflix-start-after-firefox.sh ~/mythnetflix/mythnetflix-start-before-firefox.sh ~/mythnetflix/mythnetflix-stop.sh

If you need to edit the scripts I tried to make it relatively fool proof.

  1. mythnetflix.sh -- this is the master script try to avoid editing this
  2. mythnetflix-start-before-firefox.sh -- this script will run commands before Firefox starts. I have it reset some of the LIRC settings
  3. mythnetflix-start-after-firefox.sh -- this script will run commands while Firefox is running. I have it center the mouse on the Netflix profile selector. I also included a simple hack to fix some window focus issues I've had but it is shipped disabled. See more about the weird WM_Behavior_Hack (not written yet)
  4. mythnetflix-stop.sh -- this script will run commands after firefox has closed. I have it set some LIRC settings back, edit this if you have done some customizing of LIRC using irxec or irxevent. I also included my wm behavior hack but it is disabled.

Edit Mythfrontend

To add a menu button for your theme you need to go to ~/.mythtv/themes/'the theme your using'/

note: I have been using the MythMediaStream theme

Open mainmenu.xml and add the following lines somewhere that you think fits (I put it below the videos section)

<button>
   <type>VIDEO</type>
   <text>Netflix</text>
   <description>Watch videos on</description>
   <action>EXEC ~/mythnetflix/mythnetflix.sh</action>
</button>

Now when you restart your Mythfrontend the Netflix option should show up

The Remote

the included LIRC file (which you should have put into the mythnetflix folder with the scripts) is a whole bunch of mouse position and click commands. you may need to edit it. I set it up to work with the remote I have but it should give you a good starting point to make it work. I will post some more advanced LIRC and xdtool stuff when I get a chance.

right now it will only work with mceusb remote

My remote:

Remote gms.jpg

Navigating with the remote

When in the Netflix choose video screen:

  • UP, DOWN, LEFT, RIGHT -- buttons jump 100 pixels, hold down enabled
  • 2, 8, 4, 6 -- small button steps 10 pixels at a time, hold down enabled
  • OK -- mouse click I use it to select profile (will start movie)
  • Channel UP, DOWN -- scroll the page up or down
  • ENTER -- will start movie and try to auto full screen, sometimes fails if video loading take too long
  • ← (back arrow) -- exit Netflix, returns you to Mythfrontend

When watching a video:

the UP, DOWN, LEFT, RIGHT, 2, 8, 4, 6, OK buttons do all the same thing and are to be used if needed.

Volume keys -- I added a control, but I don't use system volume controls YMMV

If you are not in full screen mode hit the # button. that will make it full screen, none of these other buttons will work if not in full screen mode.

  • # -- make video full screen. only work if video is not in full screen
  • PLAY, PAUSE -- both buttons will play or pause the video
  • STOP -- sends you back to the Netflix video chooser screen
  • FF, REW -- will put the mouse on the position bar in the middle-- bar will disappear but if you use the buttons to move along it it will re-appear, OK selects
  • DVD -- puts the mouse on the audio menu -- my remote it's the little button to the right of the mute button
  • RecTV -- puts the mouse on the HD button -- my remote it's the button to the left of the mute button
  • GREEN BUTTON -- centers the mouse on the menu bar -- kinda worthless I think

Notes for resolutions other than 1920x1080

The fancy key mapping will not work right for you.

  • UP, DOWN, LEFT, RIGHT, 2, 8, 4, 6 -- all should work as above, they are just mouse move controls.
  • OK -- should work as above, it is just a mouse click
  • Channel UP, DOWN -- should work as above

you may also want to edit line 15 of mythnetflix-start-after-firefox.sh it is set to put the mouse in about the middle of the screen. may want to change the two numbers to 640 560

The LIRC File

I had to write a bunch of mouse position and mouse click commands for this file. As of right now I don't have a 1280x720 file but am planning on working on it.

I also have it only set up for a MCEUSB remote.

Only 2 things may need changing if at all in the mythnetflix1080.lircrc file.

If your close window button is on the top right you need to change this section:

begin
    remote = mceusb
    prog = irexec
    button = KEY_BACK
    ##use setting below if close window button is on LEFT
    config = xdotool mousemove 12 12 && xdotool click 1
    ##use setting below if close window is on RIGHT
    #config = xdotool mousemove 1910 12 && xdotool click 1
    repeat = 0
    delay = 0
end

If your video load time is too long and the auto full screen is firing too early edit this section:

begin
    remote = mceusb
    prog = irexec
    button = KEY_ENTER
    ## you may need to increase the first sleep time if the video takes too long to load and it doesn't automatically go to full screen mode.
    config = xdotool click 1 && sleep 10 && xdotool mousemove 1625 955 && xdotool click 1 && sleep 1 && xdotool mousemove 1920 1080
    repeat = 0
    delay = 0
end

Problems I Have Ran Into

Everything works fine when I launch the script from the command line but when I launch it from the Mythfrontend Silverlight always crashes.

This one took a while for me to figure out how to make it work, it's not a fix per say more of a workaround. make sure you have SSH client and server enable on the machine your running Netflix on

  1. from the terminal make sure you can ssh back into your mythtv box ssh 'user'@127.0.0.1 where user is the user running Mythfrontend.
  2. exit out of the ssh session
  3. set the ssh server to allow you to login over ssh without a password ssh-copy-id 'user'@127.0.0.1
  4. try logging in again ssh 'user'@127.0.0.1
  5. exit
  6. edit your mainmenu.xml <action> to look like this. Insert username where it says user:
<action>EXEC ssh user@127.0.0.1 'env DISPLAY=:0  ~/mythnetflix/mythnetflix.sh'</action>


Mythfrontend stays on top and everything is locked up.

That is my weird wm hack I talked about. I will have to write up my fix on that soon.