コード例 #1
0
    def playInternal(self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Stop')

        try:
            self.launch_browser('http://netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Start')
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Cannot update playcount. See logfile')
        self.close()
コード例 #2
0
	def post_launch_check(self,game_launch_status=None,**kwargs):
		if game_launch_status and game_launch_status['launch_process'] and not self.settings.get('ext_launchers').get('close_kodi'):
			from subprocess import TimeoutExpired
			dp = xbmcgui.DialogProgress()
			dp.create(loc_str(30377),loc_str(30380))
			dp.update(0,loc_str(30380))
			perc = 0
			finished=False
			check=None
			while not finished:
				try:
					check = game_launch_status['launch_process'].wait(timeout=WAIT_FOR_PROCESS_EXIT)
				except TimeoutExpired:
					perc=perc+10
					dp.update(perc%100,loc_str(30380))
					finished=False
					check=None
				if dp.iscanceled():
					finished=True
					dp.close()
					break
				if isinstance(check,int):
					finished = True
					dp.close()
					break
				if finished:
					dp.close()
					break
			del dp
			if not self.settings.get('ext_launchers').get('close_kodi') and self.settings.get('ext_launchers').get('stop_audio_controller') and self.settings.get('ext_launchers').get('environment') not in ['android','android_ra32','android_aarch64']:
				xbmc.log(msg='IAGL:  Re-Enabling Audio and Controller Input',level=xbmc.LOGDEBUG)
				xbmc.audioResume()
				xbmc.enableNavSounds(True)
				xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"input.enablejoystick","value":true},"id":"1"}')
コード例 #3
0
ファイル: common.py プロジェクト: hpduong/retropie_configs
def Open_Netflix():
    import subprocess, sys
    xbmc.audioSuspend()
    ret = xbmc.executeJSONRPC(
        '{ "jsonrpc": "2.0", "id": 0, "method": "Settings.getSettingValue", "params": {"setting":"screensaver.mode" } }'
    )
    jsn = json.loads(ret)
    saver_mode = jsn['result']['value']
    xbmc.executeJSONRPC(
        '{ "jsonrpc": "2.0", "id": 0, "method":"Settings.setSettingValue", "params": {"setting":"screensaver.mode", "value":""} } '
    )
    browser = xbmcaddon.Addon('plugin.video.kodilivetv').getSetting('browser')
    if 'linux' in sys.platform:
        if browser == "Chrome":
            CHROME = os.path.join('/', 'opt', 'google', 'chrome',
                                  'google-chrome')
            if not os.path.isfile(CHROME):
                CHROME = os.path.join('/', 'usr', 'bin', 'google-chrome')
            subprocess.call([
                CHROME, '--start-maximized', '--disable-translate',
                '--disable-new-tab-first-run', '--no-default-browser-check',
                '--no-first-run', '--kiosk',
                '--app=https://www.netflix.com/browse'
            ])
            #process = subprocess.Popen(os.path.join(os.path.join(addonDir),"chrome.sh"), shell=True)
        else:
            CHROMIUM = os.path.join('/', 'usr', 'bin', 'chromium')
            if not os.path.isfile(CHROMIUM):
                CHROMIUM = os.path.join('/', 'usr', 'bin', 'chromium-browser')
            subprocess.call([
                CHROMIUM, '--start-maximized', '--disable-translate',
                '--disable-new-tab-first-run', '--no-default-browser-check',
                '--no-first-run', '--kiosk',
                '--app=https://www.netflix.com/browse'
            ])
            #process = subprocess.Popen(os.path.join(os.path.join(addonDir),"chromium.sh"), shell=True)
        #process.wait()
    if 'win32' in sys.platform:
        if browser == "Chrome":
            process = subprocess.Popen(os.path.join(os.path.join(addonDir),
                                                    "chrome.cmd"),
                                       shell=True)
        else:
            process = subprocess.Popen(os.path.join(os.path.join(addonDir),
                                                    "iexplore.cmd"),
                                       shell=True)
        process.wait()
    if 'darwin' in sys.platform:
        CHROME = os.path.join('/', 'Applications', 'Google Chrome.app',
                              'Contents', 'MacOS', 'Google Chrome')
        subprocess.call([
            CHROMIUM, '--start-fullscreen', '--kiosk',
            'https://www.netflix.com/browse'
        ])
        #process = subprocess.Popen(os.path.join(os.path.join(addonDir),"darwin.sh"), shell=True)
        #process.wait()
    xbmc.audioResume()
    xbmc.executeJSONRPC(
        '{ "jsonrpc": "2.0", "id": 0, "method": "Settings.SetSettingValue", "params": {"setting":"screensaver.mode", "value": "'
        + saver_mode + '" } }')
コード例 #4
0
    def test_sound(self, listItem=None):
        try:
            self.oe.dbg_log('sound::test_sound', 'enter_function', 0)

            str_sound_dev = self.oe.read_setting('system', 'snd-dev')
            if str_sound_dev != 'none':
                xbmc.executebuiltin('PlayerControl(Stop)')
                xbmc.audioSuspend()
                xbmc.enableNavSounds(False)
                time.sleep(2)
                snd_card = re.search('card ([\d]+)', str_sound_dev).group(1)
                snd_dev = re.search('device ([\d]+)', str_sound_dev).group(1)
                subprocess.Popen(self.SND_TEST % (int(snd_card), int(snd_dev)),
                                 shell=True,
                                 close_fds=True,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)

                xbmcDialog = xbmcgui.Dialog()
                answer = xbmcDialog.ok('Test Sound', ' ',
                                       'Device: %s' % str_sound_dev)

                self.oe.execute('killall -9 speaker-test', 0)
                time.sleep(1)
                xbmc.audioResume()
                xbmc.enableNavSounds(True)

        except Exception, e:
            self.oe.dbg_log('sound::test_sound', 'ERROR: (' + repr(e) + ')')
コード例 #5
0
    def playInternal (self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Stop')

        try:
            self.launch_browser('http://netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        if generic_utility.get_setting('disable_lirc') == 'true':
            xbmc.executebuiltin('LIRC.Start')

        if generic_utility.get_setting('sync_viewstate') == 'true':
            try:
                self.update_playcount(video_id)
            except:
                generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
                generic_utility.notification('Cannot update playcount. See logfile')
        self.close()
コード例 #6
0
 def restoreVolume(self):
     try:
         if Settings.isUseAudioSuspend():
             xbmc.audioResume()
         # Don't change the volume unless requested to
         elif self.screensaverVolume > -1:
             self._setVolume(self.original_volume)
     except:
         log("VolumeDrop: %s" % traceback.format_exc(), xbmc.LOGERROR)
コード例 #7
0
 def restoreVolume(self):
     try:
         if Settings.isUseAudioSuspend():
             xbmc.audioResume()
         # Don't change the volume unless requested to
         elif self.screensaverVolume > -1:
             self._setVolume(self.original_volume)
     except:
         log("VolumeDrop: %s" % traceback.format_exc(), xbmc.LOGERROR)
コード例 #8
0
def launchSteam():
    basePath = os.path.join(getAddonDataPath(), 'scripts')
    if osAndroid:
        cmd = "com.valvesoftware.android.steam.community"
        log('attempting to launch: "%s"' % cmd)
        xbmc.executebuiltin('XBMC.StartAndroidActivity("%s")' % cmd)
        kodiBusyDialog()
        sys.exit()
    elif osWin:
        steamlauncher = os.path.join(basePath, 'SteamLauncher-AHK.exe')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
            steamlauncher, steamWin, kodiWin, quitKodiSetting, kodiPortable,
            preScript, postScript)
        #log('Windows UTF-8 command: "%s"' % cmdutf8)
    elif osOsx:
        steamlauncher = os.path.join(basePath, 'steam-launch.sh')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
            steamlauncher, steamOsx, kodiOsx, quitKodiSetting, kodiPortable,
            preScript, postScript)
    elif osLinux:
        steamlauncher = os.path.join(basePath, 'steam-launch.sh')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
            steamlauncher, steamLinux, kodiLinux, quitKodiSetting,
            kodiPortable, preScript, postScript)
    try:
        log('attempting to launch: %s' % cmd)
        print cmd.encode('utf-8')
        if suspendAudio == 'true':
            xbmc.audioSuspend()
            log('Audio suspended')
        if quitKodiSetting == '1' and suspendAudio == 'true':
            proc_h = subprocess.Popen(cmd.encode(txt_encode),
                                      shell=True,
                                      close_fds=False)
            kodiBusyDialog()
            log('Waiting for Steam to exit')
            while proc_h.returncode is None:
                xbmc.sleep(1000)
                proc_h.poll()
            log('Start resuming audio....')
            xbmc.audioResume()
            log('Audio resumed')
            del proc_h
        else:
            subprocess.Popen(cmd.encode(txt_encode),
                             shell=True,
                             close_fds=True)
            kodiBusyDialog()

    except:
        log('ERROR: failed to launch: %s' % cmd)
        print cmd.encode(txt_encode)
        dialog.notification(language(50123), language(50126), addonIcon, 5000)
コード例 #9
0
def launchSteam():
    if osAndroid:
        cmd = "com.valvesoftware.android.steam.community"
        log('attempting to launch: "%s"' % cmd)
        xbmc.executebuiltin('XBMC.StartAndroidActivity("%s")' % cmd)
        kodiBusyDialog()
        sys.exit()
    elif osWin:
        steamlauncher = os.path.join(scripts_path, 'steam-launcher.exe')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
            steamlauncher, steamWin, kodiWin, quitKodiSetting, kodiPortable,
            preScript, postScript, steamParameters, forceKillKodi, desktopMode)
    elif osOsx:
        steamlauncher = os.path.join(scripts_path, 'steam-launcher.sh')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
            steamlauncher, steamOsx, kodiOsx, quitKodiSetting, kodiPortable,
            preScript, postScript, steamParameters, forceKillKodi, desktopMode)
    elif osLinux:
        steamlauncher = os.path.join(scripts_path, 'steam-launcher.sh')
        cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" %s' % (
            steamlauncher, steamLinux, kodiLinux, quitKodiSetting,
            kodiPortable, preScript, postScript, steamParameters,
            forceKillKodi, desktopMode,
            "> " + steamlauncher.replace('.sh', '.log'))
    try:
        log('attempting to launch: %s' % cmd)
        print cmd.encode('utf-8')
        if suspendAudio == 'true':
            xbmc.audioSuspend()
            log('Audio suspended')
        if quitKodiSetting != '0' and suspendAudio == 'true':
            proc_h = subprocess.Popen(cmd.encode(txt_encode),
                                      shell=True,
                                      close_fds=False)
            kodiBusyDialog()
            log('Waiting for Steam to exit')
            while proc_h.returncode is None:
                xbmc.sleep(1000)
                proc_h.poll()
            log('Start resuming audio....')
            xbmc.audioResume()
            log('Audio resumed')
            del proc_h
        else:
            subprocess.Popen(cmd.encode(txt_encode),
                             shell=True,
                             close_fds=True)
            kodiBusyDialog()
    except:
        log('ERROR: failed to launch: %s' % cmd)
        print cmd.encode(txt_encode)
        dialog.notification(language(50212), language(50215), addonIcon, 5000)
コード例 #10
0
def cleanup(andexit=True):

    global xbmcAudioSuspended, slaveProcess

    logNotice("Doing Cleanup")

    #are we running the locally installed Squeezeslave? KILL IT!
    if constants.PLAYBACK and slaveProcess is not None:
        logNotice("Killing player process...")
        try:
            slaveProcess.terminate()
        except Exception as inst:
            logNotice("Error killing player, probably the player crashed.  Let's try re-start it so we can grab the output for debugging!")
            #now let's try to start it again so we can log the output message for clues...
            if constants.SYSTEM.startswith("win"):
                output, result = subprocess.Popen(exe, creationflags=0x08000000, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=False).communicate()
            else:
                output, result = subprocess.Popen(exe, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=False).communicate()
            logNotice("ERROR RESULT: " + str(result))
            logNotice("ERROR OUTPUT: " + str(output))

    #Try and resume XBMC's AudioEngine if we suspended it
    if xbmcAudioSuspended:
        try:
            #pause
            if constants.SECONDS_TO_PAUSE_EXIT!=0:
                logNotice("Pausing for " + str(constants.SECONDS_TO_PAUSE_EXIT) + ", per request in XSqueeze settings.")
                notify("Pause & resume AE after " + str(constants.SECONDS_TO_PAUSE_EXIT) + " seconds.", "(per request in XSqueeze settings.)")
                time.sleep(constants.SECONDS_TO_PAUSE_EXIT)
            xbmc.audioResume();
            logNotice("Resumed XBMC AE")
        except:
            pass

    #restore auto shutdown timer
    xbmc.executebuiltin('XBMC.InhibitIdleShutdown(False)', False)
 
    #remove our custom keymap
    try:
        os.remove(constants.KEYMAPDESTFILE)
        logNotice("Removed custom keymap")
    except Exception as inst:
        pass

    #and force a re-load
    xbmc.executebuiltin('Action(reloadkeymaps)')

    #and exit if requested
    if andexit:
        footprints(startup=False)
        sys.exit()
    def postExecution(self, toggle_screen_flag):

        # --- Stop Kodi some time ---
        delay_tempo_ms = self.settings['delay_tempo']
        log_verb('postExecution() Pausing {0} ms'.format(delay_tempo_ms))
        xbmc.sleep(delay_tempo_ms)

        # --- Toggle Kodi windowed/fullscreen if requested ---
        if toggle_screen_flag:
            log_verb('postExecution() Toggling Kodi fullscreen')
            kodi_toogle_fullscreen()
        else:
            log_verb('postExecution() Toggling Kodi fullscreen DEACTIVATED in Launcher')

        # --- Resume audio engine if it was suspended ---
        # Calling xmbc.audioResume() takes a loong time (2/4 secs) if audio was not properly suspended!
        # Also produces this in Kodi's log:
        # WARNING: CActiveAE::StateMachine - signal: 0 from port: OutputControlPort not handled for state: 7
        #   ERROR: ActiveAE::Resume - failed to init
        if self.kodi_audio_suspended:
            log_verb('postExecution() Kodi audio engine was suspended before launching')
            log_verb('postExecution() Resuming Kodi audio engine')
            xbmc.audioResume()
            xbmc.enableNavSounds(True)
            xbmc.sleep(100)
        else:
            log_verb('_run_before_execution() DO NOT resume Kodi audio engine')

        # --- Resume joystick engine if it was suspended ---
        if self.kodi_joystick_suspended:
            log_verb('postExecution() Kodi joystick engine was suspended before launching')
            log_verb('postExecution() Resuming Kodi joystick engine')
            # response = xbmc.executeJSONRPC(c_str)
            # log_debug('JSON      ''{0}'''.format(c_str))
            # log_debug('Response  ''{0}'''.format(response))
            log_verb('postExecution() Not supported on Kodi Krypton!')
        else:
            log_verb('postExecution() DO NOT resume Kodi joystick engine')

        # --- Resume Kodi playing if it was paused. If it was stopped, keep it stopped. ---
        media_state_action = self.settings['media_state_action']
        media_state_str = ['Stop', 'Pause', 'Let Play'][media_state_action]
        log_verb('postExecution() media_state_action is "{0}" ({1})'.format(media_state_str, media_state_action))
        log_verb('postExecution() self.kodi_was_playing is {0}'.format(self.kodi_was_playing))
        if self.kodi_was_playing and media_state_action == 1:
            log_verb('postExecution() Calling xbmc.Player().play()')
            xbmc.Player().play()
        log_debug('postExecution() function ENDS')
コード例 #12
0
    def playInternal (self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        try:
            self.launch_browser('https://www.netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification('Cannot update playcount. See logfile')
        self.close()
コード例 #13
0
def launchSteam():
	basePath = os.path.join(getAddonDataPath(), 'scripts')
	if osAndroid:
		cmd = "com.valvesoftware.android.steam.community"
		log('attempting to launch: "%s"' % cmd)
		xbmc.executebuiltin('XBMC.StartAndroidActivity("%s")' % cmd)
		kodiBusyDialog()
		sys.exit()
	elif osWin:
		steamlauncher = os.path.join(basePath, 'SteamLauncher-AHK.exe')
		cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (steamlauncher, steamWin, kodiWin, quitKodiSetting, kodiPortable, preScript, postScript)
		#log('Windows UTF-8 command: "%s"' % cmdutf8)
	elif osOsx:
		steamlauncher = os.path.join(basePath, 'steam-launch.sh')
		cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (steamlauncher, steamOsx, kodiOsx, quitKodiSetting, kodiPortable, preScript, postScript)
	elif osLinux:
		steamlauncher = os.path.join(basePath, 'steam-launch.sh')
		cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (steamlauncher, steamLinux, kodiLinux, quitKodiSetting, kodiPortable, preScript, postScript)
	try:
		log('attempting to launch: %s' % cmd)
		print cmd.encode('utf-8')
		if suspendAudio == 'true':
			xbmc.audioSuspend()
			log('Audio suspended')
		if quitKodiSetting == '1' and suspendAudio == 'true':
			proc_h = subprocess.Popen(cmd.encode(txt_encode), shell=True, close_fds=False)
			kodiBusyDialog()
			log('Waiting for Steam to exit')
			while proc_h.returncode is None:
				xbmc.sleep(1000)
				proc_h.poll()
			log('Start resuming audio....')
			xbmc.audioResume()
			log('Audio resumed')
			del proc_h		
		else:
			subprocess.Popen(cmd.encode(txt_encode), shell=True, close_fds=True)
			kodiBusyDialog()


	except:
		log('ERROR: failed to launch: %s' % cmd)
		print cmd.encode(txt_encode)
		dialog.notification(language(50123), language(50126), addonIcon, 5000)
コード例 #14
0
def launch_playnite():
    # if this.os_android:
    #   cmd = "com.valvesoftware.android.steam.community"
    #   log('attempting to launch: "%s"' % cmd)
    #   xbmc.executebuiltin('XBMC.StartAndroidActivity("%s")' % cmd)
    #   kodi_busy_dialog()
    #   sys.exit()
    # elif this.os_win:
    if this.os_win:
        playnitelauncher = str(
            PurePath(scripts_path).joinpath('playnite-launcher.exe'))
        log(f'playnite launcher exe: {playnitelauncher}')
        playniteWin = this.playnite_desktop_win if this.desktop_mode == True else this.playnite_fullscreen_win
        cmd = f'"{playnitelauncher}" "{playniteWin}" "{this.kodi_win}" "{str(this.quit_kodi)}" "{str(this.kodi_portable).lower()}" "{this.pre_script}" "{this.post_script}" "{this.playnite_parameters}" "{str(this.force_kill_kodi)}"'
    # elif this.os_osx:
    #   playnitelauncher = os.path.join(scripts_path, 'playnite-launcher.sh')
    #   cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (playnitelauncher, this.playnite_osx, this.kodi_osx, str(this.quit_kodi), str(this.kodi_portable).lower(), this.pre_script, this.post_script, this.playnite_parameters, str(this.force_kill_kodi))
    # elif this.os_linux:
    #   playnitelauncher = os.path.join(scripts_path, 'playnite-launcher.sh')
    #   cmd = '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (playnitelauncher, this.playnite_linux, this.kodi_linux, str(this.quit_kodi), str(this.kodi_portable).lower(), this.pre_script, this.post_script, this.playnite_parameters, str(this.force_kill_kodi))
    try:
        log(f'attempting to launch: {cmd}')
        if this.suspend_audio == True:
            xbmc.audioSuspend()
            log('audio suspended')
        if this.quit_kodi != 0 and this.suspend_audio == True:
            proc_h = subprocess.Popen(cmd, shell=True, close_fds=False)
            kodi_busy_dialog()
            log('waiting for Playnite to exit')
            while proc_h.returncode is None:
                xbmc.sleep(1000)
                proc_h.poll()
            log('start resuming audio....')
            xbmc.audioResume()
            log('audio resumed')
            del proc_h
        else:
            subprocess.Popen(cmd, shell=True, close_fds=True)
            kodi_busy_dialog()
    except:
        log(f'ERROR: failed to launch: {cmd}')
        dialog.notification(language(50212), language(50215), addonIcon, 5000)
コード例 #15
0
    def playInternal(self, video_id, series_id):
        xbmc.audioSuspend()
        self.disable_screensaver()

        try:
            self.launch_browser('https://www.netflix.com/watch/%s' % video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Error launching browser. See logfile')

        self.enable_screensaver()
        xbmc.audioResume()
        try:
            self.update_playcount(video_id)
        except:
            generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
            generic_utility.notification(
                'Cannot update playcount. See logfile')
        self.close()
コード例 #16
0
def emulator_launcher():
    prevent_video_playback('start')
    selected_game = ''.join(args.get('filename'))
    launcher_script = ''.join(args.get('launcher_script'))
    rom_path = ''.join(args.get('rom_path'))
    folder_url = build_url({
        'mode': 'folder',
        'foldername': ''.join(args.get('foldername'))
    })
    f = open(RESTART_FILE, 'w')
    f.write(folder_url)
    f.close()
    system_config = os.path.join(
        SYSTEMS_CONFIG_PATH, ''.join(args.get('foldername')) + '-config.xml')
    tree = ET.parse(system_config)
    root = tree.getroot()
    if selected_game:
        for item in root.findall('game_variations'):
            for game in item.iter('game'):
                if ''.join(args.get('game_name')) in game.attrib['name']:
                    if os.path.exists(os.path.join(rom_path, selected_game)):
                        game_variation_list = []
                        game_variation_list.append(selected_game, )
                        for game_variation in os.listdir(
                                os.path.join(rom_path, selected_game)):
                            game_variation_list.append(
                                os.path.splitext(game_variation)[0], )
                        selected_var_game = dialog.select(
                            language(50200), game_variation_list)
                        if selected_var_game == -1:
                            sys.exit()
                        elif selected_var_game == 0:
                            break
                        else:
                            selected_var_game = game_variation_list[
                                selected_var_game]
                        rom_path = os.path.join(rom_path, selected_game)
                        selected_game = selected_var_game
                        if not args.get('alt_launcher'):
                            if game.find('launcher').text:
                                launcher_script = game.find('launcher').text
                    else:
                        log_message = 'Directory does not exist: ' + os.path.join(
                            rom_path, selected_game)
                        log(log_message, language(50109))
        if not args.get('alt_launcher'):
            for item in root.findall('alt_launchers'):
                for game in item.iter('game'):
                    if selected_game in game.attrib['name']:
                        launcher_script = game.find('launcher').text
        if args.get('rom_extensions') == ['false']:
            search_item = os.path.join(rom_path, selected_game + '.*')
            rom_full_path_list = glob.glob('%s' % search_item)
            rom_full_path = ''.join(rom_full_path_list[0])
        else:
            file_types = []
            file_types = ''.join(args.get('rom_extensions')).split(' ')
            for file_type in file_types:
                file_type = '.' + file_type
                rom_full_path = os.path.join(rom_path,
                                             selected_game) + file_type
                if os.path.isfile(rom_full_path):
                    break
        if not rom_full_path:
            file_check(''.join(search_item), search_item)
        rom_extension = os.path.splitext(rom_full_path)[1]
        rom_file = os.path.basename(rom_full_path)
        if launcher_script == 'kodi_retroplayer':
            listitem = xbmcgui.ListItem(rom_file, "0", "", "")
            parameters = {
                'Platform': ''.join(args.get('foldername')),
                'Title': ''.join(args.get('game_name')),
                'URL': rom_full_path
            }
            listitem.setInfo(type='game', infoLabels=parameters)
            xbmc.Player().play(rom_full_path, listitem)
        else:
            launcher_script_command = os.path.join(LAUNCHER_SCRIPTS,
                                                   launcher_script)
            file_check(launcher_script_command, launcher_script_command)
            cmd = '"%s" "%s" "%s" "%s" "%s" "%s"' % (
                launcher_script_command, ''.join(args.get('foldername')),
                selected_game, rom_full_path, rom_file, rom_extension)
            log('Attempted command is:', False)
            log(cmd, False)
            if suspendAudio == 'true':
                xbmc.audioSuspend()
                log('Suspending Kodi audio', False)
            if backgroundKodi == 'true':
                proc_h = subprocess.Popen(cmd.encode(txt_encode),
                                          shell=True,
                                          close_fds=False)
                while proc_h.returncode is None:
                    xbmc.sleep(500)
                    proc_h.poll()
                del proc_h
            else:
                subprocess.Popen(cmd.encode(txt_encode),
                                 shell=True,
                                 close_fds=True)
            prevent_video_playback('stop')
            xbmc.audioResume()
    else:
        log('No selected game', language(50110))
コード例 #17
0
def launchNonXbox(cmd, romCollection, gameRow, settings, precmd, postcmd, roms,
                  gui, listitem):
    Logutil.log("launchEmu on non-xbox", util.LOG_LEVEL_INFO)

    screenModeToggled = False

    encoding = 'utf-8'
    #HACK: sys.getfilesystemencoding() is not supported on all systems (e.g. Android)
    try:
        encoding = sys.getfilesystemencoding()
    except:
        pass

    #use libretro core to play game
    if (romCollection.useBuiltinEmulator):
        Logutil.log("launching game with internal emulator",
                    util.LOG_LEVEL_INFO)
        rom = roms[0]
        gameclient = romCollection.gameclient
        #HACK: use alternateGameCmd as gameclient
        if (gameRow[util.GAME_alternateGameCmd] != None
                and gameRow[util.GAME_alternateGameCmd] != ""):
            gameclient = str(gameRow[util.GAME_alternateGameCmd])
        Logutil.log("Preferred gameclient: " + gameclient, util.LOG_LEVEL_INFO)
        Logutil.log("Setting platform: " + romCollection.name,
                    util.LOG_LEVEL_INFO)

        if (listitem == None):
            listitem = xbmcgui.ListItem(rom, "0", "", "")

        parameters = {"platform": romCollection.name}
        if (gameclient != ""):
            parameters["gameclient"] = gameclient
        listitem.setInfo(type="game", infoLabels=parameters)
        Logutil.log("launching rom: " + rom, util.LOG_LEVEL_INFO)
        gui.player.play(rom, listitem)
        #xbmc.executebuiltin('PlayMedia(\"%s\", platform=%s, gameclient=%s)' %(rom, romCollection.name, romCollection.gameclient))
        return

    if (not romCollection.useEmuSolo):
        #screenMode = xbmc.executehttpapi("GetSystemInfoByName(system.screenmode)").replace("<li>","")
        screenMode = xbmc.getInfoLabel("System.Screenmode")
        Logutil.log("screenMode: " + screenMode, util.LOG_LEVEL_INFO)
        isFullScreen = screenMode.endswith("Full Screen")

        toggleScreenMode = settings.getSetting(
            util.SETTING_RCB_TOGGLESCREENMODE).upper() == 'TRUE'

        if (isFullScreen and toggleScreenMode):
            Logutil.log("Toggle to Windowed mode", util.LOG_LEVEL_INFO)
            #this minimizes xbmc some apps seems to need it
            try:
                xbmc.executehttpapi("Action(199)")
            except:
                xbmc.executeJSONRPC(
                    '{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"togglefullscreen"},"id":"1"}'
                )

            screenModeToggled = True

    Logutil.log("launch emu", util.LOG_LEVEL_INFO)

    #pre launch command
    if (precmd.strip() != '' and precmd.strip() != 'call'):
        Logutil.log("Got to PRE", util.LOG_LEVEL_INFO)
        os.system(precmd.encode(encoding))

    preDelay = settings.getSetting(SETTING_RCB_PRELAUNCHDELAY)
    if (preDelay != ''):
        preDelay = int(float(preDelay))
        xbmc.sleep(preDelay)

    #change working directory
    path = os.path.dirname(romCollection.emulatorCmd)
    if (os.path.isdir(path)):
        try:
            os.chdir(path)
        except:
            pass

    #pause audio
    suspendAudio = settings.getSetting(
        util.SETTING_RCB_SUSPENDAUDIO).upper() == 'TRUE'
    if (suspendAudio):
        xbmc.executebuiltin("PlayerControl(Stop)")
        xbmc.enableNavSounds(False)
        xbmc.audioSuspend()

    if (romCollection.usePopen):
        import subprocess
        process = subprocess.Popen(cmd.encode(encoding), shell=True)
        process.wait()
    else:
        try:
            os.system(cmd.encode(encoding))
        except:
            os.system(cmd.encode('utf-8'))

    Logutil.log("launch emu done", util.LOG_LEVEL_INFO)

    postDelay = settings.getSetting(SETTING_RCB_POSTLAUNCHDELAY)
    if (postDelay != ''):
        postDelay = int(float(postDelay))
        xbmc.sleep(postDelay)

    #resume audio
    if (suspendAudio):
        xbmc.audioResume()
        xbmc.enableNavSounds(True)

    #post launch command
    if (postcmd.strip() != '' and postcmd.strip() != 'call'):
        Logutil.log("Got to POST: " + postcmd.strip(), util.LOG_LEVEL_INFO)
        os.system(postcmd.encode(encoding))

    if (screenModeToggled):
        Logutil.log("Toggle to Full Screen mode", util.LOG_LEVEL_INFO)
        #this brings xbmc back
        try:
            xbmc.executehttpapi("Action(199)")
        except:
            xbmc.executeJSONRPC(
                '{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"togglefullscreen"},"id":"1"}'
            )
コード例 #18
0
def emulator_launcher():
	prevent_video_playback('start')
	selected_game = ''.join(args.get('filename'))
	launcher_script = ''.join(args.get('launcher_script'))
	rom_path = ''.join(args.get('rom_path'))
	folder_url = build_url({'mode': 'folder', 'foldername': ''.join(args.get('foldername'))})
	f = open(RESTART_FILE, 'w')
	f.write(folder_url)
	f.close()
	system_config = os.path.join(SYSTEMS_CONFIG_PATH, ''.join(args.get('foldername')) + '-config.xml')
	tree = ET.parse(system_config)
	root = tree.getroot()
	if selected_game:
		for item in root.findall('game_variations'):
			for game in item.iter('game'):
				if ''.join(args.get('game_name')) in game.attrib['name']:
					if os.path.exists(os.path.join(rom_path, selected_game)):
						game_variation_list = []
						game_variation_list.append( selected_game, )
						for game_variation in os.listdir(os.path.join(rom_path, selected_game)):
							game_variation_list.append( os.path.splitext(game_variation)[0], )
						selected_var_game = dialog.select(language(50200), game_variation_list)
						if selected_var_game == -1:
							sys.exit()
						elif selected_var_game == 0:
							break
						else:
							selected_var_game = game_variation_list[selected_var_game]
						rom_path = os.path.join(rom_path, selected_game)
						selected_game = selected_var_game
						if not args.get('alt_launcher'):
							if game.find('launcher').text:
								launcher_script = game.find('launcher').text
					else:
						log_message = 'Directory does not exist: ' + os.path.join(rom_path, selected_game)
						log(log_message, language(50109))
		if not args.get('alt_launcher'):
			for item in root.findall('alt_launchers'):
				for game in item.iter('game'):
					if selected_game in game.attrib['name']:
						launcher_script = game.find('launcher').text
		if args.get('rom_extensions') == ['false']:
			search_item = os.path.join(rom_path, selected_game + '.*')
			rom_full_path_list = glob.glob('%s' % search_item)
			rom_full_path = ''.join(rom_full_path_list[0])
		else:
			file_types = []
			file_types = ''.join(args.get('rom_extensions')).split(' ')
			for file_type in file_types:
				file_type = '.' + file_type
				rom_full_path = os.path.join(rom_path, selected_game) + file_type
				if os.path.isfile(rom_full_path):
					break
		if not rom_full_path:
			file_check(''.join(search_item), search_item)
		rom_extension = os.path.splitext(rom_full_path)[1]
		rom_file = 	os.path.basename(rom_full_path)
		if launcher_script == 'kodi_retroplayer':
			listitem = xbmcgui.ListItem(rom_file, "0", "", "")
			parameters = {'Platform': ''.join(args.get('foldername')), 'Title': ''.join(args.get('game_name')), 'URL': rom_full_path}
			listitem.setInfo( type='game', infoLabels=parameters)
			xbmc.Player().play(rom_full_path, listitem)
		else:
			launcher_script_command = os.path.join(LAUNCHER_SCRIPTS, launcher_script)
			file_check(launcher_script_command, launcher_script_command)
			cmd = '"%s" "%s" "%s" "%s" "%s" "%s"' % (launcher_script_command, ''.join(args.get('foldername')), selected_game, rom_full_path, rom_file, rom_extension)
			log('Attempted command is:', False)
			log(cmd, False)
			if suspendAudio == 'true':
				xbmc.audioSuspend()
				log('Suspending Kodi audio', False)
			if backgroundKodi == 'true':
				proc_h = subprocess.Popen(cmd.encode(txt_encode), shell=True, close_fds=False)
				while proc_h.returncode is None:
					xbmc.sleep(500)
					proc_h.poll()
				del proc_h		
			else:
				subprocess.Popen(cmd.encode(txt_encode), shell=True, close_fds=True)
			prevent_video_playback('stop')
			xbmc.audioResume()
	else:
		log('No selected game', language(50110))
コード例 #19
0
	def __audioResume(self):
		if __addon__.getSetting(util.SETTING_RCB_SUSPENDAUDIO).upper() == 'TRUE':
			log.debug("Resuming audio")
			xbmc.audioResume()
			xbmc.enableNavSounds(True)
コード例 #20
0
 def __audioResume(self):
     if __addon__.getSetting(
             util.SETTING_RCB_SUSPENDAUDIO).upper() == 'TRUE':
         log.debug("Resuming audio")
         xbmc.audioResume()
         xbmc.enableNavSounds(True)
コード例 #21
0
    subprocess.call([
        'pactl', 'set-card-profile', config['card-profile'],
        'output:' + config['card-output']
    ])
except:
    Pass
time.sleep(2)

try:
    subprocess.call(['pactl', 'set-default-sink', config['default-sink']])
except:
    Pass
time.sleep(2)

# Resume audio engine again
xbmc.audioResume()

# get all settings and options
settings = xbmc.executeJSONRPC('{"jsonrpc":"2.0",' +
                               '"method":"Settings.GetSettings", "id":1}')

# parse json settings for audio options
# this is Python 2 so no need to decode to utf-8
settings = json.JSONDecoder().decode(settings)
settings = settings['result']['settings']

# audio devices are item 120 with 'options' key
# extract just the labels for display purposes
labels = [l['label'] for l in settings[120]['options']]

line = '\n'.join(labels)
コード例 #22
0
    def launch_game(self, game_id):
        binary_path = self.config_helper.binary_path
        scripts_path = self.config_helper.launchscripts_path

        player = xbmc.Player()
        if player.isPlayingVideo():
            player.stop()

        isResumeMode = bool(self.plugin.getSetting('last_run'))
        showIntro = self.plugin.getSettingBool('show_intro')
        codec = self.config_helper.config['codec']

        if isResumeMode:
            xbmc.audioSuspend()
        else:
            self.plugin.setSettingString('last_run', game_id)

        xbmc.executebuiltin("Dialog.Close(busydialog)")
        xbmc.executebuiltin("Dialog.Close(notification)")
        xbmc.executebuiltin("InhibitScreensaver(true)")

        try:
            if showIntro and not isResumeMode:
                player.play(self.config_helper.addon_path +
                            'resources/statics/loading.mp4')
                time.sleep(10)
                player.stop()

            t0 = time.monotonic()
            subprocess.run([scripts_path + 'prescript.sh', binary_path, codec],
                           cwd=scripts_path,
                           start_new_session=True)
            launch_cmd = subprocess.Popen(
                [scripts_path + 'launch.sh', game_id],
                cwd=binary_path,
                start_new_session=True)
            launch_cmd.wait()
            subprocess.run([scripts_path + 'postscript.sh', binary_path],
                           cwd=scripts_path,
                           start_new_session=True)

        except Exception as e:
            print("Failed to execute moonlight process.")
            print(e)
        finally:
            xbmc.audioResume()
            xbmc.executebuiltin("InhibitScreensaver(false)")

            # Less than 10 seconds passed.
            if time.monotonic() - t0 < 10:
                result = xbmcgui.Dialog().yesno(
                    "",
                    "It seems that moonlight-embedded might have crashed. Create an automatic bug report?"
                )
                if result:
                    output = subprocess.check_output(
                        [scripts_path + '../../create_bug_report.sh'],
                        encoding='utf-8',
                        cwd=scripts_path + '../../',
                        start_new_session=True)
                    xbmcgui.Dialog().ok(
                        "",
                        "Report your bug on GitHub or Forums with this URL: " +
                        output)
            else:
                xbmcgui.Dialog().notification(
                    'Information', game_id +
                    ' is still running on host. Resume via Luna, ensuring to quit before the host is restarted!',
                    xbmcgui.NOTIFICATION_INFO, False)
コード例 #23
0
def cleanup(andexit=True):

    global xbmcAudioSuspended, slaveProcess

    logNotice("Doing Cleanup")

    #are we running the locally installed Squeezeslave? KILL IT!
    if constants.PLAYBACK and slaveProcess is not None:
        logNotice("Killing player process...")
        try:
            slaveProcess.terminate()
        except Exception as inst:
            logNotice(
                "Error killing player, probably the player crashed.  Let's try re-start it so we can grab the output for debugging!"
            )
            #now let's try to start it again so we can log the output message for clues...
            if constants.SYSTEM.startswith("win"):
                output, result = subprocess.Popen(exe,
                                                  creationflags=0x08000000,
                                                  stdout=subprocess.PIPE,
                                                  stderr=subprocess.PIPE,
                                                  shell=False).communicate()
            else:
                output, result = subprocess.Popen(exe,
                                                  stdout=subprocess.PIPE,
                                                  stderr=subprocess.PIPE,
                                                  shell=False).communicate()
            logNotice("ERROR RESULT: " + str(result))
            logNotice("ERROR OUTPUT: " + str(output))

    #Try and resume XBMC's AudioEngine if we suspended it
    if xbmcAudioSuspended:
        try:
            #pause
            if constants.SECONDS_TO_PAUSE_EXIT != 0:
                logNotice("Pausing for " +
                          str(constants.SECONDS_TO_PAUSE_EXIT) +
                          ", per request in XSqueeze settings.")
                notify(
                    "Pause & resume AE after " +
                    str(constants.SECONDS_TO_PAUSE_EXIT) + " seconds.",
                    "(per request in XSqueeze settings.)")
                time.sleep(constants.SECONDS_TO_PAUSE_EXIT)
            xbmc.audioResume()
            logNotice("Resumed XBMC AE")
        except:
            pass

    #restore auto shutdown timer
    xbmc.executebuiltin('XBMC.InhibitIdleShutdown(False)', False)

    #remove our custom keymap
    try:
        os.remove(constants.KEYMAPDESTFILE)
        logNotice("Removed custom keymap")
    except Exception as inst:
        pass

    #and force a re-load
    xbmc.executebuiltin('Action(reloadkeymaps)')

    #and exit if requested
    if andexit:
        footprints(startup=False)
        sys.exit()
コード例 #24
0
def launchNonXbox(cmd, romCollection, gameRow, settings, precmd, postcmd, roms, gui, listitem):
	Logutil.log("launchEmu on non-xbox", util.LOG_LEVEL_INFO)							
				
	screenModeToggled = False
		
	encoding = 'utf-8'
	#HACK: sys.getfilesystemencoding() is not supported on all systems (e.g. Android)
	try:
		encoding = sys.getfilesystemencoding()
	except:
		pass
		 
	
	#use libretro core to play game
	if(romCollection.useBuiltinEmulator):
		Logutil.log("launching game with internal emulator", util.LOG_LEVEL_INFO)
		rom = roms[0]
		gameclient = romCollection.gameclient
		#HACK: use alternateGameCmd as gameclient
		if(gameRow[util.GAME_alternateGameCmd] != None and gameRow[util.GAME_alternateGameCmd] != ""):
			gameclient = str(gameRow[util.GAME_alternateGameCmd])
		Logutil.log("Preferred gameclient: " +gameclient, util.LOG_LEVEL_INFO)
		Logutil.log("Setting platform: " +romCollection.name, util.LOG_LEVEL_INFO)
		
		if(listitem == None):
			listitem = xbmcgui.ListItem(rom, "0", "", "")
		
		parameters = { "platform": romCollection.name }
		if(gameclient != ""):
			parameters["gameclient"] = gameclient
		listitem.setInfo( type="game", infoLabels=parameters)
		Logutil.log("launching rom: " +rom, util.LOG_LEVEL_INFO)		
		gui.player.play(rom, listitem)
		#xbmc.executebuiltin('PlayMedia(\"%s\", platform=%s, gameclient=%s)' %(rom, romCollection.name, romCollection.gameclient))
		return
	
	if (not romCollection.useEmuSolo):
		#screenMode = xbmc.executehttpapi("GetSystemInfoByName(system.screenmode)").replace("<li>","")
		screenMode = xbmc.getInfoLabel("System.Screenmode")
		Logutil.log("screenMode: " +screenMode, util.LOG_LEVEL_INFO)
		isFullScreen = screenMode.endswith("Full Screen")
		
		toggleScreenMode = settings.getSetting(util.SETTING_RCB_TOGGLESCREENMODE).upper() == 'TRUE'
		
		if(isFullScreen and toggleScreenMode):
			Logutil.log("Toggle to Windowed mode", util.LOG_LEVEL_INFO)
			#this minimizes xbmc some apps seems to need it
			try:
				xbmc.executehttpapi("Action(199)")
			except:
				xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"togglefullscreen"},"id":"1"}')
			
			screenModeToggled = True
		
	Logutil.log("launch emu", util.LOG_LEVEL_INFO)
	
	#pre launch command
	if(precmd.strip() != '' and precmd.strip() != 'call'):
		Logutil.log("Got to PRE", util.LOG_LEVEL_INFO)
		os.system(precmd.encode(encoding))
	
	preDelay = settings.getSetting(SETTING_RCB_PRELAUNCHDELAY)
	if(preDelay != ''):
		preDelay = int(float(preDelay))
		xbmc.sleep(preDelay)
	
	#change working directory
	path = os.path.dirname(romCollection.emulatorCmd)
	if(os.path.isdir(path)):
		try:
			os.chdir(path)
		except:
			pass
	
		
	#pause audio
	suspendAudio = settings.getSetting(util.SETTING_RCB_SUSPENDAUDIO).upper() == 'TRUE'
	if(suspendAudio):
		xbmc.executebuiltin("PlayerControl(Stop)")
		xbmc.enableNavSounds(False)
		xbmc.audioSuspend()
	
	if(romCollection.usePopen):
		import subprocess
		process = subprocess.Popen(cmd.encode(encoding), shell=True)
		process.wait()
	else:
		try:
			os.system(cmd.encode(encoding))
		except:
			os.system(cmd.encode('utf-8'))
	
	Logutil.log("launch emu done", util.LOG_LEVEL_INFO)		
	
	postDelay = settings.getSetting(SETTING_RCB_POSTLAUNCHDELAY)
	if(postDelay != ''):
		postDelay = int(float(postDelay))
		xbmc.sleep(postDelay)
	
	#resume audio
	if(suspendAudio):
		xbmc.audioResume()
		xbmc.enableNavSounds(True)
	
	#post launch command
	if(postcmd.strip() != '' and postcmd.strip() != 'call'):
		Logutil.log("Got to POST: " + postcmd.strip(), util.LOG_LEVEL_INFO)
		os.system(postcmd.encode(encoding))
	
	if(screenModeToggled):
		Logutil.log("Toggle to Full Screen mode", util.LOG_LEVEL_INFO)
		#this brings xbmc back
		try:
			xbmc.executehttpapi("Action(199)")
		except:
			xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"togglefullscreen"},"id":"1"}')
コード例 #25
0
ファイル: default.py プロジェクト: lrusak/multimedia.steam
def resumeXbmc():
  xbmc.audioResume()
  xbmc.enableNavSounds(True)
コード例 #26
0
    def _run_rom(self, launcherID, romName):
        if (self.launchers.has_key(launcherID)):
            launcher = self.launchers[launcherID]
            if (launcher["roms"].has_key(romName)):
                rom = self.launchers[launcherID]["roms"][romName]
                romfile = os.path.basename(rom["filename"])
                if ( rom["altapp"] != "" ):
                    application = rom["altapp"]
                else:
                    application = launcher["application"]
                apppath = os.path.dirname(application)
                rompath = os.path.dirname(rom["filename"])
                romname = os.path.splitext(romfile)[0]
    
                if ( os.path.exists(apppath) ) :
                    if ( os.path.exists(rom["filename"]) ) :
                        files = []
                        filesnames = []
                        ext3s = ['.cd1', '-cd1', '_cd1', ' cd1']
                        for ext3 in ext3s:
                            cleanromname = re.sub('(\[.*?\]|\{.*?\}|\(.*?\))', '', romname)
                            if ( cleanromname.lower().find(ext3) > -1 ):
                                temprompath = os.path.dirname(rom["filename"])
                                try:
                                    filesnames = os.listdir(temprompath)
                                except:
                                    notification(addonName + " - " + addonString(30612).encode('utf-8'),addonString(30610).encode('utf-8'),"",3000)
                                namestem = cleanromname[:-len(ext3)]

                                for filesname in filesnames:
                                    altname=re.findall('\{.*?\}',filesname)
                                    searchname = re.sub('(\[.*?\]|\{.*?\}|\(.*?\))', '', filesname)
                                    if searchname[0:len(namestem)] == namestem and searchname[len(namestem):len(namestem)+len(ext3) - 1]  == ext3[:-1]:
                                        for romext in launcher["romext"].split("|"):
                                            if searchname[-len(romext):].lower() == romext.lower() :
                                                Discnum = searchname[(len(namestem)+len(ext3)-1):searchname.rfind(".")]
                                                try:
                                                    int(Discnum)
                                                    if not altname:
                                                        files.append([Discnum, xbmc.getLocalizedString(427)+" "+Discnum, os.path.join(os.path.dirname(rom["filename"]),filesname)])
                                                    else:
                                                        files.append([Discnum, altname[0][1:-1], os.path.join(os.path.dirname(rom["filename"]),filesname)])
                                                except:
                                                    pass
                                if len(files) > 0:
                                    files.sort(key=lambda x: int(x[0]))
                                    discs = []
                                    for file in files:
                                        discs.append(file[1])
                                    dialog = xbmcgui.Dialog()
                                    type3 = dialog.select("%s:" % addonString_servicefeatherence(32423).encode('utf-8'), discs)
                                    if type3 > -1 :
                                        myresult = files[type3]
                                        rom["filename"] = myresult[2]
                                        romfile = os.path.basename(rom["filename"])
                                        rompath = os.path.dirname(rom["filename"])
                                        romname = os.path.splitext(romfile)[0]
                                    else:
                                        return ""

                        if ( rom["altarg"] != "" ):
                            arguments = rom["altarg"]
                        else:
                            arguments = launcher["args"]
                        arguments = arguments.replace("%rom%" , rom["filename"]).replace("%ROM%" , rom["filename"])
                        arguments = arguments.replace("%romfile%" , romfile).replace("%ROMFILE%" , romfile)
                        arguments = arguments.replace("%romname%" , romname).replace("%ROMNAME%" , romname)
                        arguments = arguments.replace("%rombasename%" , base_filename(romname)).replace("%ROMBASENAME%" , base_filename(romname))
                        arguments = arguments.replace("%apppath%" , apppath).replace("%APPPATH%" , apppath)
                        arguments = arguments.replace("%rompath%" , rompath).replace("%ROMPATH%" , rompath)
                        arguments = arguments.replace("%romtitle%" , rom["name"]).replace("%ROMTITLE%" , rom["name"])
                        arguments = arguments.replace("%romspath%" , launcher["rompath"]).replace("%ROMSPATH%" , launcher["rompath"])

                        if ( os.path.basename(application).lower().replace(".exe" , "") == "xbmc" ):
                            xbmc.executebuiltin('XBMC.' + arguments)
                        else:
                            if ( xbmc.Player().isPlaying() ) or 1 + 1 == 2:
								xbmc.Player().stop()
								xbmc.sleep(self.settings[ "start_tempo" ]+100)
								try:
									xbmc.audioSuspend()
								except:
								    pass
                            if (launcher["minimize"] == "true"):
                                _toogle_fullscreen()
                            try:
                                xbmc.enableNavSounds(False)                                 
                            except:
                                pass
                            xbmc.sleep(self.settings[ "start_tempo" ])
                            if (os.environ.get( "OS", "xbox" ) == "xbox"):
                                f=open(SHORTCUT_FILE, "wb")
                                f.write("<shortcut>\n")
                                f.write("    <path>" + application + "</path>\n")
                                f.write("    <custom>\n")
                                f.write("       <game>" + rom["filename"] + "</game>\n")
                                f.write("    </custom>\n")
                                f.write("</shortcut>\n")
                                f.close()
                                xbmc.executebuiltin('XBMC.Runxbe(' + SHORTCUT_FILE + ')')
                            else:
                                if (sys.platform == 'win32'):
                                    if ( launcher["lnk"] == "true" ) and ( launcher["romext"] == "lnk" ):
                                        os.system("start \"\" \"%s\"" % (arguments))
                                    else:
                                        if ( application.split(".")[-1] == "bat" ):
                                            info = subprocess_hack.STARTUPINFO()
                                            info.dwFlags = 1
                                            info.wShowWindow = 0
                                        else:
                                            info = None
                                        startproc = subprocess_hack.Popen(r'%s %s' % (application, arguments), cwd=apppath, startupinfo=info)
                                        startproc.wait()
                                elif (sys.platform.startswith('linux')):
                                    if ( self.settings[ "lirc_state" ] ):
                                        xbmc.executebuiltin('LIRC.stop')
                                    os.system("\"%s\" %s " % (application, arguments))
                                    if ( self.settings[ "lirc_state" ] ):
                                        xbmc.executebuiltin('LIRC.start')
                                elif (sys.platform.startswith('darwin')):
                                    os.system("\"%s\" %s " % (application, arguments))
                                else:
                                    notification(addonName + " - " + addonString(30612).encode('utf-8'),addonString(30609).encode('utf-8'),"",3000)
                            xbmc.sleep(self.settings[ "start_tempo" ])
                            try:
                                xbmc.enableNavSounds(True)                            
                            except:
                                pass
                            if (launcher["minimize"] == "true"):
                                _toogle_fullscreen()
                            try:
								xbmc.audioResume()
                            except:
								pass
                    else:
                        notification(addonString(30611).encode('utf-8') % os.path.basename(rom["filename"]),'You should download the game first!','',3000)
                else:
                    notification(addonName + " - " + addonString(30612).encode('utf-8'),addonString(30611).encode('utf-8') % os.path.basename(launcher["application"]),"",3000)
コード例 #27
0
sep = ' '
string = sep.join(args)

# Evaluate DEBUG in settings.xml and assign log path
if __addon__.getSetting('DEBUG') == 'true':
    output = user_log
elif __addon__.getSetting('DEBUG') == 'false':
    output = '/dev/null'

# Copy environment
env = os.environ.copy()
# Add libs folder to environment
env['LD_LIBRARY_PATH'] = os.path.join(__cwd__, 'libs')

# Suspend XBMC's audio stream 
try:
    xbmc.audioSuspend()
except:
    pass

# Launch RetroArch with selected flags and environment
p = subprocess.Popen([helper_script, service, string, output], env=env, preexec_fn=os.setpgrp)
# Wait for process to terminate before continuing
p.wait()

# Enable XBMC's audio stream
try:
    xbmc.audioResume()
except:
    pass
コード例 #28
0
    def _run_launcher(self, launcherID):
        if (self.launchers.has_key(launcherID)):
            launcher = self.launchers[launcherID]
            apppath = os.path.dirname(launcher["application"])
            if ( os.path.basename(launcher["application"]).lower().replace(".exe" , "") == "xbmc" ) or ("xbmc-fav-" in launcher["application"]) or ("xbmc-sea-" in launcher["application"]):
                xbmc.executebuiltin('XBMC.%s' % launcher["args"])
            else:
                if ( os.path.exists(apppath) ) :
                    arguments = launcher["args"].replace("%apppath%" , apppath).replace("%APPPATH%" , apppath)
                    if xbmc.Player().isPlaying() or 1 + 1 == 2:
						xbmc.Player().stop()
						xbmc.sleep(self.settings[ "start_tempo" ]+100)
						try:
							xbmc.audioSuspend()
						except:
							pass
                    if (launcher["minimize"] == "true"):
                        _toogle_fullscreen()
                    try:
                        xbmc.enableNavSounds(False)                                 
                    except:
                        pass
                    xbmc.sleep(self.settings[ "start_tempo" ])
                    if (os.environ.get( "OS", "xbox" ) == "xbox"):
                        xbmc.executebuiltin('XBMC.Runxbe(' + launcher["application"] + ')')
                    else:
                        if (sys.platform == 'win32'):
                            if ( launcher["application"].split(".")[-1] == "lnk" ):
                                os.system("start \"\" \"%s\"" % (launcher["application"]))
                            else:
                                if ( launcher["application"].split(".")[-1] == "bat" ):
                                    info = subprocess_hack.STARTUPINFO()
                                    info.dwFlags = 1
                                    info.wShowWindow = 0
                                else:
                                    info = None
                                startproc = subprocess_hack.Popen(r'%s %s' % (launcher["application"], arguments), cwd=apppath, startupinfo=info)
                                startproc.wait()
                        elif (sys.platform.startswith('linux')):
                            if ( self.settings[ "lirc_state" ] ):
                                xbmc.executebuiltin('LIRC.stop')
                            os.system("\"%s\" %s " % (launcher["application"], arguments))
                            if ( self.settings[ "lirc_state" ] ):
                                xbmc.executebuiltin('LIRC.start')
                        elif (sys.platform.startswith('darwin')):
                            os.system("\"%s\" %s " % (launcher["application"], arguments))
                        else:
                            notification(addonName + " - " + addonString(30612).encode('utf-8'),addonString(30609).encode('utf-8'),"",3000)
                    xbmc.sleep(self.settings[ "start_tempo" ])
                    if (launcher["minimize"] == "true"):
                        _toogle_fullscreen()
                    try:
                        xbmc.enableNavSounds(True)                            
                    except:
                        pass
					
                    try:
						xbmc.audioResume()
                    except:
						pass
                else:
                    notification(addonName + " - " + addonString(30612).encode('utf-8'),addonString(30611).encode('utf-8') % os.path.basename(launcher["application"]),"",3000)
コード例 #29
0
def resumeXbmc():
    if pauseXBMC == "true":
        xbmc.audioResume()
        xbmc.enableNavSounds(True)