rjw57 / yt

Experiments with the YouTube API
MIT License
83 stars 25 forks source link

Window size for omxplayer #12

Open kosl opened 11 years ago

kosl commented 11 years ago

recent omxplayer on raspberry pi allows window size specification. The following patch introduces such an option to yt command line.

diff -urN whitey-0.3/src/yt/__init__.py whitey-0.3-patched/src/yt/__init__.py
--- whitey-0.3/src/yt/__init__.py       2013-03-21 20:24:14.000000000 +0100
+++ whitey-0.3-patched/src/yt/__init__.py       2013-05-25 15:38:26.865483420 +0200
@@ -15,6 +15,7 @@
 # Define possible player modes.
 MPLAYER_MODE="mplayer"
 OMXPLAYER_MODE="omxplayer"
+WINDOW=""

 def main():
     """
@@ -23,9 +24,14 @@

     # Allow the user to specify whether to use mplayer or omxplayer for playing videos.
     parser = argparse.ArgumentParser(prog='yt',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-    parser.add_argument("--player",default=MPLAYER_MODE,choices=[MPLAYER_MODE,OMXPLAYER_MODE],help="specifies what program to use to play videos")
+    parser.add_argument("--player",default=OMXPLAYER_MODE,choices=[MPLAYER_MODE,OMXPLAYER_MODE],help="specifies what program to use to play videos")
+
+    parser.add_argument("--win", help="specify window position for omxplayer")

     args = parser.parse_args(sys.argv[1:])
+    global WINDOW
+    if (args.win):
+       WINDOW=args.win

     ui = Ui(args.player)
     ui.run()
@@ -401,9 +407,14 @@
     player.wait()

 def play_url_omxplayer(url):
-    player = subprocess.Popen(
-            ['omxplayer', '-ohdmi', url.decode('UTF-8').strip()],
+    if (len(WINDOW)) :
+       player = subprocess.Popen(
+            ['omxplayer', '--win', WINDOW, 
+           url.decode('UTF-8').strip()],
             stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+    else :
+       player = subprocess.Popen(['omxplayer',url.decode('UTF-8').strip()],
+               stdout = subprocess.PIPE, stderr = subprocess.PIPE)
     player.wait()

 def search(terms):
rjw57 commented 11 years ago

Is there a strong reason to change the default player as well as adding the --win option?

kosl commented 11 years ago

Oops. You can disregard this default player part of the patch. One thing to suggest, maybe, is that there are many other options from the omxplayer or mplayer would like to pass besides --win. This patch is just a first request for that.

d10si commented 10 years ago

@kosl hi,I found your patch interesting is there any chance you can update this to yt 4.0 and add option for passing -r to omxplayer?