Play sounds at task end.
14806
def on_taskend(self, task):
        
        key = 'timer' if task.elapsed else 'end'
        filename = self.files.get(key)

        if filename:
            self._play_sound(filename)
128134
def play_Track(self, track, channel=1, bpm=120):
        """"""
        self.notify_listeners(self.MSG_PLAY_TRACK, {'track': track, 'channel'
                              : channel, 'bpm': bpm})
        for bar in track:
            res = self.play_Bar(bar, channel, bpm)
            if res != {}:
                bpm = res['bpm']
            else:
                return {}
        return {'bpm': bpm}
647885
protected void playSound (SoundKey key)
    {
        if (!key.running) {
            return;
        }
        key.thread = Thread.currentThread();
        SourceDataLine line = null;
        try {
            // get the sound data from our LRU cache
            byte[] data = getClipData(key);
            if (data == null) {
                return; // borked!

            } else if (key.isExpired()) {
                if (_verbose.getValue()) {
                    log.info("Sound expired [key=" + key.key + "].");
                }
                return;

            }

            AudioInputStream stream = setupAudioStream(data);

            if (key.isLoop() && stream.markSupported()) {
                stream.mark(data.length);
            }

            // open the sound line
            AudioFormat format = stream.getFormat();
            line = (SourceDataLine)AudioSystem.getLine(
                new DataLine.Info(SourceDataLine.class, format));
            line.open(format, LINEBUF_SIZE);
            float setVolume = 1;
            float setPan = PAN_CENTER;
            line.start();

            _soundSeemsToWork = true;
            long startTime = System.currentTimeMillis();

            byte[] buffer = new byte[LINEBUF_SIZE];
            int totalRead = 0;
            do {
                // play the sound
                int count = 0;
                while (key.running && count != -1) {
                    float vol = key.volume;
                    if (vol != setVolume) {
                        adjustVolume(line, vol);
                        setVolume = vol;
                    }
                    float pan = key.pan;
                    if (pan != setPan) {
                        adjustPan(line, pan);
                        setPan = pan;
                    }
                    try {
                        count = stream.read(buffer, 0, buffer.length);
                        totalRead += count; // The final -1 will make us slightly off, but that's ok

                    } catch (IOException e) {
                        // this shouldn't ever ever happen because the stream
                        // we're given is from a reliable source
                        log.warning("Error reading clip data!", e);
                        return;
                    }

                    if (count >= 0) {
                        line.write(buffer, 0, count);
                    }
                }

                if (key.isLoop()) {
                    // if we're going to loop, reset the stream to the beginning if we can,
                    // otherwise just remake the stream
                    if (stream.markSupported()) {
                        stream.reset();
                    } else {
                        stream = setupAudioStream(data);
                    }
                }
            } while (key.isLoop() && key.running);

            // sleep the drain time. We never trust line.drain() because
            // it is buggy and locks up on natively multithreaded systems
            // (linux, winXP with HT).
            float sampleRate = format.getSampleRate();
            if (sampleRate == AudioSystem.NOT_SPECIFIED) {
                sampleRate = 11025; // most of our sounds are
            }
            int sampleSize = format.getSampleSizeInBits();
            if (sampleSize == AudioSystem.NOT_SPECIFIED) {
                sampleSize = 16;
            }

            // Calculate the numerator as a long as a decent sized clip * 8000 can overflow an int
            int drainTime = (int) Math.ceil((totalRead * 8 * 1000L) / (sampleRate * sampleSize));

            // subtract out time we've already spent doing things.
            drainTime -= System.currentTimeMillis() - startTime;

            drainTime = Math.max(0, drainTime);

            // add in a fudge factor of half a second
            drainTime += 500;

            try {
                Thread.sleep(drainTime);
            } catch (InterruptedException ie) { }

        } catch (IOException ioe) {
            log.warning("Error loading sound file [key=" + key + ", e=" + ioe + "].");

        } catch (UnsupportedAudioFileException uafe) {
            log.warning("Unsupported sound format [key=" + key + ", e=" + uafe + "].");

        } catch (LineUnavailableException lue) {
            String err = "Line not available to play sound [key=" + key.key + ", e=" + lue + "].";
            if (_soundSeemsToWork) {
                log.warning(err);
            } else {
                // this error comes every goddamned time we play a sound on someone with a
                // misconfigured sound card, so let's just keep it to ourselves
                log.debug(err);
            }

        } finally {
            if (line != null) {
                line.close();
            }
            key.thread = null;
        }
    }
242427
private void playTrack(SoundCloudTrack track) {
        pauseTimer();
        try {
            // acquire lock on wifi.
            mWifiLock.acquire();

            mIsPaused = false;
            mIsPausedAfterAudioFocusChanged = false;
            mHasAlreadyPlayed = true;

            // 1 - UPDATE ALL VISUAL CALLBACK FIRST TO IMPROVE USER EXPERIENCE

            updateNotification();
            // update playback state as well as meta data.
            mMediaSession.setPlaybackState(MediaSessionWrapper.PLAYBACK_STATE_PLAYING);
            // start loading of the artwork.
            loadArtwork(this,
                    SoundCloudArtworkHelper.getArtworkUrl(track, SoundCloudArtworkHelper.XXXLARGE));
            // broadcast events
            Intent intent = new Intent(PlaybackListener.ACTION_ON_TRACK_PLAYED);
            intent.putExtra(PlaybackListener.EXTRA_KEY_TRACK, track);
            mLocalBroadcastManager.sendBroadcast(intent);
            Intent bufferingStart = new Intent(PlaybackListener.ACTION_ON_BUFFERING_STARTED);
            mLocalBroadcastManager.sendBroadcast(bufferingStart);

            // 2 - THEN PREPARE THE TRACK STREAMING

            // set media player to stop state in order to be able to call prepare.
            mMediaPlayer.reset();

            // set new data source
            mMediaPlayer.setDataSource(track.getStreamUrl() + SOUND_CLOUD_CLIENT_ID_PARAM
                    + mSoundCloundClientId);

            // Try to gain the audio focus before preparing and starting the media player.
            if (mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN)
                    == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
                // prepare asynchronously the stream to be able to handle new action on the
                // service thread such as a pause command.
                mIsPreparing = true;
                mMediaPlayer.prepareAsync();
            }

        } catch (IOException e) {
            Log.e(TAG, "File referencing not exist : " + track);
        }
    }
23453
def play(self):
        """"""
        if self.state == STATE_PAUSED:
            self._player.set_state(Gst.State.PLAYING)
            self.state = STATE_PLAYING
793762
public void add(Sound sound) {
    assert !start || listener == null;
    ++total;
    sound.addCallback(callback);
  }
1142340
def listen(self, callback=None):
        """"""
        self._running = True
        self.loop.create_task(self._async_listen(callback))
502579
def play_sound(self, subject='Find My iPhone Alert'):
        
        data = json.dumps({
            'device': self.content['id'],
            'subject': subject,
            'clientContext': {
                'fmly': True
            }
        })
        self.session.post(
            self.sound_url,
            params=self.params,
            data=data
        )
2817
function onAudioLoad(e) {
    if (audio.soundSource === undefined) {
    // create a sound source
      audio.soundSource = audio.context.createMediaElementSource(audio.element);
    } else {
      audio.soundSource.disconnect();
    }

    // Connectors
    audio.soundSource.connect(audio.analyser);
    audio.soundSource.connect(audio.splitter);

    // Sound is loaded and ready to start playing
    audio.loaded = true;
  }
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)
902806
def play_sound(filename)
      path = Java::limelight.Context.fs.path_to(scene.path, filename)
      @peer.play_sound(path)
    end
608686
def task(ft):
	
	ft.pack(expand = True,  fill = BOTH,  side = TOP)
	pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
	pb_hD.pack(expand = True, fill = BOTH, side = TOP)
	pb_hD.start(50)
	ft.mainloop()
338773
def handle_play_clicked(self):
        
        if self.__hardware_source:
            if self.is_playing:
                self.__hardware_source.stop_playing()
            else:
                self.__hardware_source.start_playing()
1186088
def toggle_play_pause(self):
        """"""
        # Use Play/Pause button only for sources which support NETAUDIO
        if (self._state == STATE_PLAYING and
                self._input_func in self._netaudio_func_list):
            return self._pause()
        elif self._input_func in self._netaudio_func_list:
            return self._play()
1089003
function(id) {
			if (!Crafty.support.audio || !id || !this.sounds[id])
				return;
			var s = this.sounds[id];
			if (s.obj.paused)
				s.obj.play();
		}
1012842
def play(self):
        """"""
        self._response['shouldEndSession'] = True
        self._response['action']['audio']['interface'] = 'play'
        self._response['action']['audio']['sources'] = []
        return self
14558
def handle_play_pause_clicked(self):
        
        if self.__scan_hardware_source:
            if self.is_playing:
                self.__scan_hardware_source.stop_playing()
            else:
                self.__scan_hardware_source.start_playing()