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)
@ -660,3 +675,21 @@ class PlayUtils():
}
]
}
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

@ -55,6 +55,7 @@
<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="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="" />