Play an audio file asynchronously.

        :param file_path: the path to the file to play.
        :param on_done: callback when audio playback completes.
974623
def play_async(cls, file_path, on_done=None):
        
        thread = threading.Thread(
            target=AudioPlayer.play, args=(file_path, on_done,))
        thread.start()
150990
def at_line(context, file, line)
      return if file && TRACE_IGNORE_FILES.include?(File.expand_path(file))

      # If stopped for a breakpoint or catchpoint, can't play any delayed steps
      # as they'll move away from the interruption point. (Unsure if scenario is
      # possible, but just keeping assertions in check.)
      @delayed = Hash.new(0) unless :step == context.stop_reason

      if @delayed[:next] > 1     # If any delayed nexts/steps, do 'em.
        step_over @delayed[:next] - 1
        @delayed = Hash.new(0)

      elsif @delayed[:step] > 1
        step @delayed[:step] - 1
        @delayed = Hash.new(0)

      elsif @delayed[:finish] > 0
        finish
        @delayed = Hash.new(0)

      else  # Otherwise, resume the pry session at the stopped line.
        resume_pry context
      end
    end
1072816
async def play(self, ctx, *, query):
        """"""

        source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
        ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)

        await ctx.send('Now playing: {}'.format(query))
563952
def _play_sound(self, filename):
        

        command = self._get_external_player()
        if not command:
            return  # no player found

        if common.IS_MACOSX:
            command += ' "{0}"'.format(filename)
        else:
            # append quiet flag and filename
            is_play = (command == 'play')
            command += ' -q "{0}"'.format(filename)

            # HACK: play can default to using pulseaudio. here, we
            # check if pulse command exists and delegate to alsa if
            # not
            if is_play and not common.which('pulseaudio'):
                command += ' -t alsa'

        # play sound file, ignore if it fails
        common.shell_process(command, background=True)
806286
def eventlog(self, path):
        
        self.logger.debug("Parsing Event log file %s.", path)

        with NamedTemporaryFile(buffering=0) as tempfile:
            self._filesystem.download(path, tempfile.name)

            file_header = FileHeader(tempfile.read(), 0)

            for xml_string, _ in evtx_file_xml_view(file_header):
                yield xml_string
1090564
def run(self):
        
        for fn in glob_all(self.args.random_data_folder, '*.wav'):
            if fn in self.trained_fns:
                print('Skipping ' + fn + '...')
                continue

            print('Starting file ' + fn + '...')
            self.train_on_audio(fn)
            print('\r100%                 ')

            self.trained_fns.append(fn)
            save_trained_fns(self.trained_fns, self.args.model)
386030
public static void play(Context context, String clientId, SoundCloudTrack track) {
        Intent intent = new Intent(context, PlaybackService.class);
        intent.setAction(ACTION_PLAY);
        intent.putExtra(BUNDLE_KEY_SOUND_CLOUD_CLIENT_ID, clientId);
        intent.putExtra(BUNDLE_KEY_SOUND_CLOUD_TRACK, track);
        context.startService(intent);
    }
1281762
def open(self, file_path):
        

        if self.is_opened() and self.workbook.file_path == file_path:
            self._logger.logger.debug("workbook already opened: {}".format(self.workbook.file_path))
            return

        self.close()
        self._open(file_path)
1063903
def play(file_path, host=jps.env.get_master_host(), pub_port=jps.DEFAULT_PUB_PORT):
    '''
    '''
    pub = jps.Publisher('*', host=host, pub_port=pub_port)
    time.sleep(0.2)
    last_time = None
    print('start publishing file {}'.format(file_path))
    with open(file_path, 'r') as f:
        # super hack to remove header
        f.readline()
        f.readline()
        for line in f:
            if line.startswith(']}'):
                break
            publish_time, raw_msg = json.loads(line.rstrip(',\n'))
            if last_time is not None:
                time.sleep(publish_time - last_time)
            pub.publish(raw_msg.rstrip())
            last_time = publish_time
    print('fnished')
615246
async def create_ffmpeg_player(self, filepath):
        """"""
        self.current_download_elapsed = 0

        self.streamer = self.vclient.create_ffmpeg_player(filepath, after=self.vafter_ts)
        self.state = "ready"
        await self.setup_streamer()

        try:
            # Read from the info json
            info_filename = "{}.info.json".format(filepath)
            with open(info_filename, 'r') as file:
                info = json.load(file)

                self.nowplayinglog.debug(info["title"])
                self.is_live = False

                if "duration" in info and info["duration"] is not None:
                    self.current_duration = info["duration"]
                else:
                    self.current_duration = 0

                if "uploader" in info:
                    self.nowplayingauthorlog.info(info["uploader"])
                else:
                    self.nowplayingauthorlog.info("Unknown")

                self.nowplayingsourcelog.info(api_music.parse_source(info))

                play_state = "Streaming" if self.is_live else "Playing"
                await self.set_topic("{} {}".format(play_state, info["title"]))
                self.statuslog.debug(play_state)
        except Exception as e:
            logger.exception(e)
995857
def run(self):
		
		if not hasattr(self, 'queue'):
			raise RuntimeError("Audio queue is not intialized.")

		chunk = None
		channel = None
		self.keep_listening = True
		while self.keep_listening:
			if chunk is None:
				try:
					frame = self.queue.get(timeout=queue_timeout)
					chunk = pygame.sndarray.make_sound(frame)
				except Empty:
					continue

			if channel is None:
				channel = chunk.play()
			else:
				if not channel.get_queue():	
					channel.queue(chunk)
					chunk = None
			time.sleep(0.005)
		
		if not channel is None and pygame.mixer.get_init():
			channel.stop()
			pygame.mixer.quit()
634540
def play_sound(self, sound_file):
        
        self.stop_sound()
        if sound_file:
            cmd = self.check_commands(["ffplay", "paplay", "play"])
            if cmd:
                if cmd == "ffplay":
                    cmd = "ffplay -autoexit -nodisp -loglevel 0"
                sound_file = os.path.expanduser(sound_file)
                c = shlex.split("{} {}".format(cmd, sound_file))
                self._audio = Popen(c)
450693
public FileSender sendFile(String filePath, final Handler<AsyncResult<Void>> doneHandler) {
    final File file = new File(filePath);
    output.vertx().fileSystem().exists(file.getAbsolutePath(), new Handler<AsyncResult<Boolean>>() {
      @Override
      public void handle(AsyncResult<Boolean> result) {
        if (result.failed()) {
          new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
        } else if (!result.result()) {
          new DefaultFutureResult<Void>(new IOException("File not found.")).setHandler(doneHandler);
        } else {
          output.group("file", file.getName(), new Handler<OutputGroup>() {
            @Override
            public void handle(final OutputGroup group) {
              output.vertx().fileSystem().open(file.getAbsolutePath(), new Handler<AsyncResult<AsyncFile>>() {
                @Override
                public void handle(AsyncResult<AsyncFile> result) {
                  if (result.failed()) {
                    new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
                  } else {
                    doSendFile(result.result(), group, doneHandler);
                  }
                }
              });
            }
          });
        }
      }
    });
    return this;
  }
332038
function shouldProcess (filePath, done) {
        done(!!multimatch(filePath, transform.pattern, transform.opts).length)
      }
580882
def handle(self, *file_paths, **options):
        
        import os

        for file_path in file_paths:
            if not os.path.isfile(file_path):
                print("File %s not found." % file_path)
                continue
            f = open(file_path, 'r')
            data = f.readlines()
            f.close()

            self.parse_lines(data)
512327
def play_audio(filename: str):
    
    import platform
    from subprocess import Popen

    player = 'play' if platform.system() == 'Darwin' else 'aplay'
    Popen([player, '-q', filename])
1057063
function(file) {

      var defer = new $.Deferred(),
        size = file.size,
        $media = file.type === 'VIDEO' ? $('<video>') : $('<audio>'),
        onMediaLoaded = function() {
          log('File Loaded:' + file.source);

          _bytesLoaded += size;

          onElementLoaded(file, $media[0]);

          _files[_currentSegment].splice(0, 1);

          $media.off();
          $media = null;

          updatePercentage();
          defer.resolve();
        };

      // if it is a mobile or an iPad we avoid the media preloading
      if (!_isMobile && !_isTablet) {

        $media.on('loadstart', function() {
          if (this.networkState === 3) {
            onMediaError(file, this);
            onMediaLoaded();
          }
        });

        $media.on('error stalled', function() {
          onMediaError(file, this);
          onMediaLoaded();
        });

        // on Media Progress
        $media.on('loadedmetadata', function() {
          $media.on('progress', function() {
            var bytesTmpLoaded = 0;
            log('loading in progress file:' + file.source);
            if (this.buffered.length > 0) {
              bytesTmpLoaded = (size / this.duration) * this.buffered.end(0);
              size -= bytesTmpLoaded;
              _bytesLoaded += bytesTmpLoaded;
              updatePercentage();
              // Check if the video has been buffered enough to be considered preloaded
              if (1 / size * bytesTmpLoaded > mediaBufferSizeToPreload && !forceMediaPreload)
                onMediaLoaded();
            }
          });
        });

        $media.attr({
          preload: 'auto',
          src: file.source,
          controls: 'controls'
        });

        // let the browser decide when the media file has been buffered enough
        // to be played
        if (forceMediaPreload)
          $media.on('canplaythrough', onMediaLoaded);

      } else {
        //  that means that media is loaded by default
        onMediaLoaded();
      }


      return defer.promise();
    }