add resolution limit (#90)

This commit is contained in:
andreas-woelfl 2017-07-29 03:43:48 +02:00 committed by angelblue05
parent 41d56b53c3
commit 82c02594cb
4 changed files with 40 additions and 4 deletions

View file

@ -354,6 +354,6 @@
<string id="33093">Backup folder</string>
<string id="33094">Select content type to repair</string>
<string id="33095">Failed to retrieve latest updates using fast sync, using full sync.</string>
<string id="33096">Important, cleanonupdate was removed in your advanced settings to prevent conflict with Emby for Kodi. Kodi will restart now.</string>
<string id="33096">Limit video resolution to screen resolution</string>
<string id="33097">Important, cleanonupdate was removed in your advanced settings to prevent conflict with Emby for Kodi. Kodi will restart now.</string>
</strings>

View file

@ -347,4 +347,6 @@
<string id="33086">Alle zwischengespeicherten Bilder entfernen?</string>
<string id="33087">Alle Emby Addon-Einstellungen zurücksetzen?</string>
<string id="33088">Zurücksetzen der Datenbank abgeschlossen, Kodi wird nun neustarten um die Änderungen anzuwenden.</string>
<string id="33096">Video Auflösung auf Bildschirm Auflösung limitieren</string>
</strings>

View file

@ -168,6 +168,11 @@ class PlayUtils():
log.info("Can't direct play, server doesn't allow/support it.")
return False
# Verify screen resolution
if self.resolutionConflict():
log.info("Can't direct play, resolution limit is enabled")
return False
location = self.item['LocationType']
if location == "FileSystem":
# Verify the path
@ -271,6 +276,11 @@ class PlayUtils():
log.info("The network speed is insufficient to direct stream file.")
return False
# Verify screen resolution
if self.resolutionConflict():
log.info("Can't direct stream, resolution limit is enabled")
return False
return True
def directStream(self):
@ -331,6 +341,11 @@ class PlayUtils():
if transcodeHi10P == "true":
playurl = "%s&MaxVideoBitDepth=8" % playurl
# Adjust video resolution
if self.resolutionConflict():
screenRes = self.getScreenResolution()
playurl = "%s&maxWidth=%s&maxHeight=%s" % (playurl, screenRes['width'], screenRes['height'])
user_token = downloadutils.DownloadUtils().get_token()
playurl += "&api_key=" + str(user_token)
@ -659,4 +674,22 @@ class PlayUtils():
"DidlMode": ""
}
]
}
}
def resolutionConflict(self):
if settings('limitResolution') == "true":
screenRes = self.getScreenResolution()
videoRes = self.getVideoResolution()
return videoRes['width'] > screenRes['width'] or videoRes['height'] > screenRes['height']
else:
return False
def getScreenResolution(self):
wind = xbmcgui.Window()
return {'width' : wind.getWidth(),
'height' : wind.getHeight()}
def getVideoResolution(self):
return {'width' : self.item['MediaStreams'][0]['Width'],
'height' : self.item['MediaStreams'][0]['Height']}

View file

@ -54,7 +54,8 @@
<setting id="videoBitrate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|25.0 Mbps HD|30.0 Mbps HD|35.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="true" default="20" subsetting="true" />
<setting id="enableExternalSubs" type="bool" label="Enable external subs for direct stream" default="true" />
<setting id="transcodeH265" type="enum" label="30522" default="0" values="Disabled|480p(and higher)|720p(and higher)|1080p" />
<setting id="transcodeHi10P" type="bool" label="30537" default="false"/>
<setting id="transcodeHi10P" type="bool" label="30537" default="false"/>
<setting id="limitResolution" type="bool" label="33096" default="false"/>
<setting id="markPlayed" type="number" visible="false" default="90" />
<setting id="failedCount" type="number" visible="false" default="0" />
<setting id="networkCreds" type="text" visible="false" default="" />