private void StopSoundDownload() { //no players if (audioSourceToPlayPepperSound == null) { return; } //not available if (_audioDevice == null) { return; } //not downloading if (_soundDownloader == null) { return; } //Unity resources audioSourceToPlayPepperSound.Stop(); _clipDownloadedSound = null; _clipPositionToSetData = 0; //Pepper resources _audioDevice.Unsubscribe(DownloadSoundModuleName); _session.UnregisterService(_soundDownloaderRegisterId); _soundDownloader = null; _soundDownloaderRegisterId = 0; }
private void StartSoundDownload() { //no player if (audioSourceToPlayPepperSound == null) { return; } //not available if (_audioDevice == null) { return; } //already downloading if (_soundDownloader != null) { return; } //Unity側の再生設定 _clipDownloadedSound = AudioClip.Create(DownloadSoundClipName, DownloadSoundFrequency * DownloadSoundClipLengthSec, 1, DownloadSoundFrequency, true); audioSourceToPlayPepperSound.clip = _clipDownloadedSound; //Pepper側のダウンロード開始 _audioDevice.SetClientPreferences(DownloadSoundModuleName, DownloadSoundFrequency, 3, 0); _soundDownloader = CreateSoundDownloader(); //_soundDownloaderRegisterId = (uint)_session // .RegisterService(DownloadSoundModuleName, _soundDownloader) // .GetUInt64(0); _soundDownloaderRegisterId = _session .RegisterService(DownloadSoundModuleName, _soundDownloader); _audioDevice.Subscribe(DownloadSoundModuleName); //レイテンシ無いと安定しない(ハズな)ので注意 audioSourceToPlayPepperSound.loop = true; audioSourceToPlayPepperSound.PlayDelayed(DownloadSoundPlayLatency); }