Jump to content


Photo

Default aspect ratio in Freeplayer plugin


  • Please log in to reply
26 replies to this topic

#1 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 15 November 2014 - 13:15

Hi,

 

I'm using this light mediaplayer plugin Freeplayer, because he can handle all subtitle formats and have a mediaframework (eplayer & gstreamer) switcher integrated so i can watch all my movies.

The problem is i allways use 4:3 aspect ratio and i have to push five time the aspect ratio button to select 4:3.

Is there a way to modify the plugin to start by default with this aspect selection ?.

Here is the pugin ( source ) with the Freeplayer.py where i think the modifications have to be made.

I'm not a specialist so if anyone can help me it would be great.

 

Regards

 

 

 

 

 

Attached Files



Re: Default aspect ratio in Freeplayer plugin #2 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 16 November 2014 - 14:56

you can play with these lines to put what you want ,from lines seem aspect 3:4 in the first one,why you need to push fife times to get it

from what remote button you change the aspect ratio?



	def getAspectString(self,aspectnum):
		return {0: _("4:3 Letterbox"), 1: _("4:3 PanScan"), 2: _("16:9"), 3: _("16:9 always"), 4: _("16:10 Letterbox"), 5: _("16:10 PanScan"), 6: _("16:9 Letterbox")}[aspectnum]

	def setAspect(self,aspect):
		map = {0: "4_3_letterbox", 1: "4_3_panscan", 2: "16_9", 3: "16_9_always", 4: "16_10_letterbox", 5: "16_10_panscan",  6: "16_9_letterbox"}
		config.av.aspectratio.setValue(map[aspect])
		AVSwitch().setAspectRatio(aspect)

Edited by mfaraj57, 16 November 2014 - 14:58.


Re: Default aspect ratio in Freeplayer plugin #3 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 16 November 2014 - 22:30

Thank you Mfaraj17

 

I've already tried to play with those lines you mentioned with no result.

Changing the aspect ratio is done with green button but only after a small change in freeplayer.py

Before

 

self["actions"] = ActionMap(["FreePlayerActions"],
            {
                "ok": self.Ok,
                "cancel": self.Exit,
                "up": self.up,
                "down": self.down,
                "left": self.left,
                "right": self.right,
                "stop": self.Exit,
                "pause": self.pause,
                "play": self.play,
                "info": self.info,
                "key3": self.key3,
                "key6": self.key6,
                "key9": self.key9,
                "key1": self.key1,
                "key4": self.key4,
                "key7": self.key7,
                "channelup": self.channelup,
                "channeldown": self.channeldown,
                "red": self.play,
                "green": self.pause,
                "yellow": self.Exit,
                "blue": self.color,
                "text": self.text,
                "key0": self.bWidth,
                "star": self.av,
                "audio": self.audioselect,
                "menu": self.menu
            }

After

 

self["actions"] = ActionMap(["FreePlayerActions"],
            {
                "ok": self.Ok,
                "cancel": self.Exit,
                "up": self.up,
                "down": self.down,
                "left": self.left,
                "right": self.right,
                "stop": self.Exit,
                "pause": self.pause,
                "play": self.play,
                "info": self.info,
                "key3": self.key3,
                "key6": self.key6,
                "key9": self.key9,
                "key1": self.key1,
                "key4": self.key4,
                "key7": self.key7,
                "channelup": self.channelup,
                "channeldown": self.channeldown,
                "red": self.play,
                "yellow": self.Exit,
                "blue": self.color,
                "text": self.text,
                "key0": self.bWidth,
                "green": self.av,
                "audio": self.audioselect,
                "menu": self.menu
            }


Edited by oxejatte, 16 November 2014 - 22:30.


Re: Default aspect ratio in Freeplayer plugin #4 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 16 November 2014 - 22:52

Then simply put  self.setAspect(0) in the def __init__  sub,zero mean aspect ration 4:3,every time you open the freeplayer your aspect ratio chosen automatically









class FreePlayer(Screen):

	def __init__(self, session,openmovie,opensubtitle,media):
		self.media = media
		self.session = session
		self.frameon = 1 / 24
		self.seeksubtitle = 0
		self.nrsubtitle = 0
		self.enablesubtitle = True
		self.statesubtitle = "Show"
		self.stateplay = "Stop"
		self.stateinfo = "Hide"
		#self.stateinfo = "Time1"
		self.oldinfo = ""
		self.openmovie = openmovie
		self.opensubtitle = opensubtitle
		self.subtitle = []
		self.fontpos = 540
		self.fontsize = 60
		self.fontpos_ = self.fontpos
		self.fontsize_ = self.fontsize
		self.fonttype_nr = 0
		self.fonttype_nr_ = self.fonttype_nr
		self.fontcolor_nr = 0
		self.fontcolor_nr_ = self.fontcolor_nr
		self.borderWidth = 3
		self.borderWidth_ = self.borderWidth
		self.loadfont()
		self.loadcolor()
		self.loadconfig()
		if self.opensubtitle == "": self.enablesubtitle = False
		print "FontPos = ",self.fontpos
		print "FontSize = ",self.fontsize
		print "FontType = ",self.fonttype_nr
		print "FontColor = ",self.fontcolor_nr
		print "borderWidth = ",self.borderWidth
		print "OpenMovie : ",self.openmovie
		print "OpenSubtitle : ",self.opensubtitle
		self.skin = """
				<screen name="FreePlayer" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="transparent">
					<widget name="i1" position="0,540" size="1280,300" valign="bottom" halign="center" font="%s;%d" backgroundColor="transparent"/>
					<widget name="info1" position="15,15" size="825,50" halign="left" valign="top" font="Regular;40" backgroundColor="transparent"/>
					<widget name="info2" position="845,15" size="420,50" halign="right" valign="top" font="Regular;40" backgroundColor="transparent"/>
				</screen>""" % (self.fonttype_list[self.fonttype_nr],self.fontsize)
		Screen.__init__(self, session)
		self["i1"] = Label()
		self["info1"] = Label()
		self["info2"] = Label()
		self["actions"] = ActionMap(["FreePlayerActions"],
			{
				"ok": self.Ok,
				"cancel": self.Exit,
				"up": self.up,
				"down": self.down,
				"left": self.left,
				"right": self.right,
				"stop": self.Exit,
				"pause": self.pause,
				"play": self.play,
				"info": self.info,
				"key3": self.key3,
				"key6": self.key6,
				"key9": self.key9,
				"key1": self.key1,
				"key4": self.key4,
				"key7": self.key7,
				"channelup": self.channelup,
				"channeldown": self.channeldown,
				"red": self.play,
				"green": self.pause,
				"yellow": self.Exit,
				"blue": self.color,
				"text": self.text,
				"key0": self.bWidth,
				"star": self.av,
				"audio": self.audioselect,
				"menu": self.menu
			},-2)
		self.setAspect(0)
		self.ServiceName = ""
		self.onShown.append(self.__LayoutFinish)
		self.onClose.append(self.__onClose)
		self.old_policy = self.getPolicy()
		self.tout = eTimer()
		self.tout.callback.append(self.toutEvent)
#		self.tout.start(2000,false)
		self.tinfo = eTimer()
		self.tinfo.callback.append(self.tinfoEvent)

Attached Files


Edited by mfaraj57, 16 November 2014 - 22:56.


Re: Default aspect ratio in Freeplayer plugin #5 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 17 November 2014 - 00:51

Thank you very much,i've made the modifications and it works !!!

Most important i've learned something new today ;-)



Re: Default aspect ratio in Freeplayer plugin #6 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 17 November 2014 - 18:37

Digging a little more solve a problem on exit, aspect ratio stays on 4:3 when watching normals channels on TV

Here's the change ( added the line in red )

 

    def Exit(self):
        self.stateplay = "Stop"
        self.timer.stop()
        self.session.nav.stopService()
        self.setAspect(6)
        self.close()

 

Now investigating with subtitles, if someone want to join, welcome !!!

 

To do :

Remove/Play subtitles with tags (bold,italic,color)

Choice for embedded subtitles in movies ( actually only audio tracks can be selected)

 

I think after that it woud be the perfect player for people like me who have problems playing movies (can't be played with internal movieplayer or Mediaplayer2)


Edited by oxejatte, 17 November 2014 - 18:38.


Re: Default aspect ratio in Freeplayer plugin #7 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 17 November 2014 - 21:05

you can integrate susbsupports for freeplayer,offer download and playing subtitles 



Re: Default aspect ratio in Freeplayer plugin #8 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 17 November 2014 - 22:38

Yes would be great Mfaraj57, i looked into the code of Mediaplayer2 and EMC with SubsSupport, read the Wiki  to try to understand how SubsSupport is integrated but it's beyond my knowledge :-(



Re: Default aspect ratio in Freeplayer plugin #9 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 18 November 2014 - 10:27

you have to copy some lines to freeplayers and install susbsupport

if will see later if have time to add the lines to freeplayer



Re: Default aspect ratio in Freeplayer plugin #10 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 18 November 2014 - 13:42

Thank you

 

I found this line of code in plugin.py of Mediaplayer2

 

    from Plugins.Extensions.SubsSupport import SubsSupport, initSubsSettings
except ImportError as e:
    traceback.print_exc()
    raise Exception("Please install SubsSupport plugin")

Then

 

class MediaPlayer(Screen, InfoBarBase, SubsSupport, InfoBarSeek, InfoBarAudioSelection, MyInfoBarCueSheetSupport, InfoBarNotifications, InfoBarAspectChange, HelpableScreen):
    ALLOW_SUSPEND = True
    ENABLE_RESUME_SUPPORT = True

    def __init__(self, session, args=None):
        Screen.__init__(self, session)
        InfoBarAudioSelection.__init__(self)
        InfoBarBase.__init__(self, steal_current_service=True)
        InfoBarNotifications.__init__(self)
        # for external subtitles
        initSubsSettings()
        SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)

 

But i guess it's not as simple as that, just adding thoses lines, code that handle subs in Freeplayer have to be removed



Re: Default aspect ratio in Freeplayer plugin #11 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 18 November 2014 - 15:18

yes these true lines and there additional but not necessory at this time

try these line first and install subsstring and press text button and see if subssupport launched or not

if text button does other tasks in freeplayer remove it from actionmap block


Edited by mfaraj57, 18 November 2014 - 15:19.


Re: Default aspect ratio in Freeplayer plugin #12 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 18 November 2014 - 17:58

Tried but didn't know where to place

 

        # for external subtitles
        initSubsSettings()
        SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)

Without having errors : unexpected ident



Re: Default aspect ratio in Freeplayer plugin #13 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 18 November 2014 - 18:06



                # for external subtitles
                initSubsSettings()
                SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)
		
		if self.opensubtitle == "": self.enablesubtitle = False
		print "FontPos = ",self.fontpos
		print "FontSize = ",self.fontsize
		print "FontType = ",self.fonttype_nr
		print "FontColor = ",self.fontcolor_nr
		print "borderWidth = ",self.borderWidth
		print "OpenMovie : ",self.openmovie
		print "OpenSubtitle : ",self.opensubtitle
		self.skin = """
				<screen name="FreePlayer" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="transparent">
					<widget name="i1" position="0,540" size="1280,300" valign="bottom" halign="center" font="%s;%d" backgroundColor="transparent"/>
					<widget name="info1" position="15,15" size="825,50" halign="left" valign="top" font="Regular;40" backgroundColor="transparent"/>
					<widget name="info2" position="845,15" size="420,50" halign="right" valign="top" font="Regular;40" backgroundColor="transparent"/>
				</screen>""" % (self.fonttype_list[self.fonttype_nr],self.fontsize)
		Screen.__init__(self, session)
		self["i1"] = Label()
		self["info1"] = Label()
		self["info2"] = Label()
		self["actions"] = ActionMap(["FreePlayerActions"],
			{
				"ok": self.Ok,
				"cancel": self.Exit,
				"up": self.up,
				"down": self.down,
				"left": self.left,
				"right": self.right,
				"stop": self.Exit,
				"pause": self.pause,
				"play": self.play,
				"info": self.info,
				"key3": self.key3,
				"key6": self.key6,
				"key9": self.key9,
				"key1": self.key1,
				"key4": self.key4,
				"key7": self.key7,
				"channelup": self.channelup,
				"channeldown": self.channeldown,
				"red": self.play,
				"green": self.pause,
				"yellow": self.Exit,
				#"blue": self.color,
				"text": self.text,
				"key0": self.bWidth,
				"blue": self.av,
				"audio": self.audioselect,
				"menu": self.menu
			},-2)

put like this,indentation is important to python

also remove  "text": self.text,   from  ActionMap block


Edited by mfaraj57, 18 November 2014 - 18:08.


Re: Default aspect ratio in Freeplayer plugin #14 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 18 November 2014 - 19:54

Thank you

 

Do i have to change (in green) and remove (in red) those lines

 

class FreePlayer(Screen):

    def __init__(self, session,SubsSupport,openmovie,opensubtitle,media):
        self.media = media
        self.session = session
        self.frameon = 1 / 24
        self.seeksubtitle = 0
        self.nrsubtitle = 0
        self.enablesubtitle = True
        self.statesubtitle = "Show"
        self.stateplay = "Stop"
        self.stateinfo = "Hide"
        #self.stateinfo = "Time1"
        self.oldinfo = ""
      
 self.openmovie = openmovie
        self.opensubtitle = opensubtitle
        self.subtitle = []
        self.fontpos = 540
        self.fontsize = 60
        self.fontpos_ = self.fontpos
        self.fontsize_ = self.fontsize
        self.fonttype_nr = 0
        self.fonttype_nr_ = self.fonttype_nr
        self.fontcolor_nr = 0
        self.fontcolor_nr_ = self.fontcolor_nr
        self.borderWidth = 3
        self.borderWidth_ = self.borderWidth
        self.loadfont()
        self.loadcolor()
        self.loadconfig()

        if self.opensubtitle == "": self.enablesubtitle = False
        print "FontPos = ",self.fontpos
        print "FontSize = ",self.fontsize
        print "FontType = ",self.fonttype_nr
        print "FontColor = ",self.fontcolor_nr
        print "borderWidth = ",self.borderWidth
        print "OpenMovie : ",self.openmovie
        print "OpenSubtitle : ",self.opensubtitle



Re: Default aspect ratio in Freeplayer plugin #15 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 18 November 2014 - 21:21

No just add the two lines mentioned

tomorrow i will send to you freeplayer with subssupport



Re: Default aspect ratio in Freeplayer plugin #16 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 18 November 2014 - 22:36

Ok i managed to add the lines correctly ( thank you for you explanation :rolleyes: ), the plugin load properly but when i start a movie enigma crashes.

 

The log

 

>>  /media/net/Movies/MyMovie.mkv
.mkv
>>  /media/net/Movies/MyMovie.srt
.srt
[SubsSupport] using global config
[SubsSupport] initializing config
[SubsSupport] looking for custom colors in /usr/lib/enigma2/python/Plugins/Extensions/SubsSupport/colors.txt
[SubsSupport] adding custom color customcolor1
Screen <class 'Plugins.Extensions.FreePlayer.FreePlayer.FreePlayer'>(('/media/net/Movies/MyMovie.mkv', '/media/net/Movies/MyMovie.srt', 2), {}): <type 'exceptions.TypeError'>
Traceback (most recent call last):
  File "/usr/lib/enigma2/python/mytest.py", line 226, in create
    return screen(self, *arguments, **kwargs)
  File "/usr/lib/enigma2/python/Plugins/Extensions/FreePlayer/FreePlayer.py", line 104, in __init__
    SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)
TypeError: unbound method __init__() must be called with SubsSupport instance as first argument (got FreePlayer instance instead)

 

The line 104

 

        self.loadcolor()
        self.loadconfig()
                # for external subtitles
                initSubsSettings()
                SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)
        
        if self.opensubtitle == "": self.enablesubtitle = False
 

 

Try to find myself the solution without boring you, but i think i'll have to wait for your modified plugin



Re: Default aspect ratio in Freeplayer plugin #17 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 19 November 2014 - 12:52

Hi,

Here is a guide which you should follow to successfully integrate subssupport in your mediaplayer:

 

1. SubsSupport expects that InfoBarBase class is present and initialized, so it can track events of current service
2. SubsSupport expects that InfoBarSeek methods are present (doSeekRelative, doSeek) so it can extend these methods for synchronization of external subtitles after seeking, meaning that you should inherit from InfoBarSeek

from Plugins.Extensions.SubsSupport import SubsSupport

class MediaPlayer(Screen, InfoBarBase, SubsSupport, InfoBarSeek):
    def __init__(self, session, args=None):
        Screen.__init__(self, session)
        InfoBarBase.__init__(self, steal_current_service=True)
        SubsSupport.__init__(self, embeddedSupport=True, searchSupport=True)
        InfoBarSeek.__init__(self)

Some notes:
-  In case Mediaplayer class is inheriting from InfoBarSubtitleSupport then don't use it, subssupport is handling embedded subtitles too(embeddedSupport=True).
-  initSubsSettings is not neccessary anymore, it will use global settings if not provided. Use it only if you don't want to share subtitles settings with other plugins, providing ConfigSubsection as parameter, where settings will be initialized.
-  In case you also want to be able to dynamically change timing of external subtitles you have to create methods for it(for now) in Mediaplayer class (look for subsDelayInc, subsDelayDec in MP2), add them to actions, bind these actions to keys in keymap..


Edited by mx3L, 19 November 2014 - 12:52.


Re: Default aspect ratio in Freeplayer plugin #18 oxejatte

  • Senior Member
  • 80 posts

+1
Neutral

Posted 19 November 2014 - 14:39

Thank you Mx3l

 

Step by step i try to understand the process of integration and sure it's not easy as you explained.

 

Freeplayer is attractive because of it lightness and most of all because it's universal with the framework switcher and solve (for me) the compatibilty problem for some movies that can't be read by MP2 or internal movieplayer.

 

Keeping that in mind, i'm wondering if it wouldn't be better to add some lines of code in the plugin himself as a classic search/replace & remove tags (bold,italic,color) to finaly preserve a standalone plugin.

 

I'm learnig a lot in this topic (thank you both) and i'm waiting for Mfaraj57 modifications to study how he managed the integration.



Re: Default aspect ratio in Freeplayer plugin #19 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 19 November 2014 - 23:33

Attached freeplayer according to guide of mx3L

 

 

Attached Files



Re: Default aspect ratio in Freeplayer plugin #20 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 20 November 2014 - 09:29

Thanks mx3L for useful information

i integrated subsupports with the player of TSmedia but  subsDelayInc, subsDelayDec do not synchronize subtitles .also in mp2,did i miss something?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users