def audiooutput_play(device, output_samples, num_bytes): global g_playbackStarted if not g_pipesManager.exists(AO_PIPE_NAME): return 0 # NUM_OF_BYTES = 64 # sentBytes = 0 # buf[NUM_OF_BYTES]; # while sentBytes < num_bytes: # chunkSize = NUM_OF_BYTES # if sentBytes < NUM_OF_BYTES: # chunkSize = num_bytes - sentBytes # memcpy(buf, (char*) output_samples + sentBytes, chunkSize); # log(xbmc.LOGDEBUG,"num_bytes: " + str(num_bytes)) if airplay.airplay_blockAirtunes(): log(xbmc.LOGDEBUG,"Suppressing AirTunes - iOS 5 client only checks drm for video airplay...") return 1 if not g_pipesManager.write(AO_PIPE_NAME, string_at(output_samples,num_bytes)): return 0 #on first packet - start playback and show viz if not g_playbackStarted: g_playbackStarted = True log(xbmc.LOGDEBUG,"Starting playback") xbmc.executebuiltin("Dialog.Close(busydialog)") listitem = xbmcgui.ListItem() listitem.setInfo('music', {'title' : 'Streaming'}) listitem.setProperty('mimetype', 'audio/x-xbmc-pcm') xbmc.Player(xbmc.PLAYER_CORE_PAPLAYER).play(AO_PIPE_NAME, listitem) xbmc.executebuiltin("ActivateWindow(WINDOWVISUALISATION)") # sentBytes += n; return 1;
def audiooutput_close(device): global g_playbackStarted #fix airplay video for ios5 devices #on ios5 when airplaying video #the client first opens an airtunes stream #while the movie is loading #in that case we don't want to stop the player here #because this would stop the airplaying video if not airplay.airplay_blockAirtunes(): xbmc.executebuiltin('PlayerControl(Stop)') log(xbmc.LOGDEBUG, "AirPlay not running - stopping player"); xbmc.executebuiltin("Dialog.Close(busydialog)") else: log(xbmc.LOGDEBUG, "AirPlay video running - player isn't stopped"); g_pipesManager.setEof(AO_PIPE_NAME) g_pipesManager.flush(AO_PIPE_NAME) g_pipesManager.closePipe(AO_PIPE_NAME) g_playbackStarted = False return 0