LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   MPlayer GUI (gmplayer - NOT gnome-mplayer) single instance fix... (https://www.linuxquestions.org/questions/linux-desktop-74/mplayer-gui-gmplayer-not-gnome-mplayer-single-instance-fix-858876/)

poweredbydodge 01-26-2011 04:39 PM

MPlayer GUI (gmplayer - NOT gnome-mplayer) single instance fix...
 
So I finally made the leap to a single media player. Long gone are the days of VLC + MPlayer + Xine-UI + XMMS + whatever... why bother? MPlayer (or more properly stated, its 'stock' GUI) has come well far enough that it serves as an all-in-one without repute.

So... enter my issue.

Every time I click on a music of movie file, bang, a new unique instance of the MPlayer GUI is launched, leaving me with two songs playing at once, or a song and a movie, etc... etc...

So, I putz around through the manpage, looking for an answer. There is none; and the wiki states that it is a 'known issue'.

The spin-off Gnome MPlayer front end (command is gnome-mplayer rather than gmplayer), has a 'single instance' flag that can be used, however it simply blocks you from opening a second file, rather then enqueing and auto-playing the second file clicked (whilst stopping the first one). So, it was of no help.

Then, it dawned on me... simple is simple is simple is... stupid?

gmplayer-hack.sh
Code:

#!/bin/bash
# MPLAYER GUI HACK FOR SINGLE INSTANCES WITH SELF START
#
item_to_play=$1
killall -9 gmplayer
gmplayer $item_to_play &
#

Then simply edit your audio and video file auto launches to use /usr/bin/gmplayer-hack.sh rather than /usr/bin/gmplayer

I then proceeded to smack myself on the forehead and become ashamed for not having thought of it earlier.

I post this here for posterity, as hopefully someone else looking for the "mplayer gui prevent multiple instance or instances" fix will find it, as I searched Google to no avail for a good half hour before realizing the folly.

Enjoy,
- Vince.

corp769 01-26-2011 05:26 PM

Quite dirty, but simple and effective. Nice job man! :P

David the H. 01-26-2011 10:43 PM

The big problem there is that you can only play one file at a time with it, and you can't pass it any other options.

Changing item_to_play=$1 to item_to_play="$@" will help correct that.

Even shorter: killall -9 gmplayer && gmplayer. You can set it up as an alias too.

But I personally don't see how you can think it's possible to go with a single player yet. I still run across videos that will only work correctly in one player or another. There's just too much variability involved in multimedia for any one solution to be able to handle them all.

nanobahr 04-11-2011 06:45 PM

works great but !!!!
 
this script working great but if your video file name contain any spaces it wont play it !!

how to fix that ?

poweredbydodge 04-12-2011 06:56 AM

Quote:

Originally Posted by nanobahr (Post 4321581)
this script working great but if your video file name contain any spaces it wont play it !!

how to fix that ?


Code:

#!/bin/bash
# MPLAYER GUI HACK FOR SINGLE INSTANCES WITH SELF START
# -- WHITESPACE FRIENDLY
#
item_to_play=$1
killall -9 gmplayer
gmplayer "$item_to_play" &
#

there ya go.

nanobahr 04-12-2011 03:34 PM

poweredbydodge thanks man >>>> your script working great .


All times are GMT -5. The time now is 11:34 PM.