public async override Task <bool> CheckIfAvailable() { var newtrack = new SoundCloudTrack { SoundCloudID = ((ApiResult)Result).id }; try { using (var x = await newtrack.GetSoundSource()) { _soundSourceInfo = SoundSourceInfo.FromSoundSource(x); return(true); } } catch (Exception) { return(false); } }
public override async Task <bool> CheckIfAvailable() { var result = new YouTubeTrack { YouTubeId = YouTubeTrack.GetYouTubeIdFromLink(Url) }; try { using (var x = await result.GetSoundSource()) { _soundSourceInfo = SoundSourceInfo.FromSoundSource(x); return(true); } } catch (Exception) { return(false); } }
/* public static void OnBrowserChange(TabInfo[] tabInfos) // TODO: maybe make this smart so that it doesn't have to look at every rule every time the user opens/closes a tab { //NOTE: We do this only for the browser that the tabinfos belong to bool matchingRuleFound = false; float maxVolume = 1.0f; for (int i = 0; i < tabInfos.Length; i++) { //TODO: do a lookup in each dict to see if there is a rule for this tabinfo. //If so, set matchingRuleFound to true. If rule indicates lower volume, update maxVolume. } if ((matchingRuleFound == false) && (MuteByDefault == true)) maxVolume = 0.0f; // TODO: set the browser's volume to maxVolume }*/ #endregion Other #if WINDOWS public static void OnUpdateSoundSourceInfos(SoundSourceInfo[] soundSourceInfos) { // TODO: send a message via socket indicating if there is sound coming from the browser or not }
// This gets called when an active sound has been added or removed // v4 of algorithm - for new mutetunes design public static void OnUpdateSoundSourceInfos(SoundSourceInfo[] soundSourceInfos) { bool BgMusicHeard = false; bool NonBgMusicHeard = false; // Dictionary<int, SoundSourceInfo> ssiDict = new Dictionary<int, SoundSourceInfo>(); SoundServer.SoundSourceInfos = soundSourceInfos; //TODO: if volume was changed for mutetunes or for bg music, update the other so that they are in sync // Determine if background music and any non-background music sound is active NonBgMusicHeard = false; for (int i = 0; i < SoundServer.SoundSourceInfos.Length; i++) { SoundSourceInfo info = SoundServer.SoundSourceInfos[i]; //ssiDict[info.Pid] = info; if (!info.IsSilentRightNow()) { LastTimeHeardDict[info.Pid] = DateTime.Now; } if (BgMusicPids.Contains(info.Pid)) { BgMusicHeard = !info.IsSilentRightNow(); UserWantsBgMusic = true; if (!info.IsActiveInterval2()) // We use a shorter interval here than for foreground sounds for better UI responsiveness and since it is more likely that sound will be continuous { UpdateMusicState(BgMusicState.Pause); // Assume it is paused if we haven't heard background music in awhile } else { if (info.ChannelVolumeIsMuted()) { UpdateMusicState(BgMusicState.Mute); } else { UpdateMusicState(BgMusicState.Play); } } } else { if (info.IsActiveForAwhile() == true) { NonBgMusicHeard = true; } } } if ((UserWantsBgMusic)) { if ((NonBgMusicHeard == true) && (BgMusicHeard == true)) { AutoMuted = true; SmartMute(); } else if ((AutoMuted == true) && (NonBgMusicHeard == false)) { AutoMuted = false; Restore(); //TODO: Need to have this run in ui thread if it sets up the browser control } } //LatestSoundSourceInfoDict = ssiDict; }
// This gets called when an active sound has been added or removed // v4 of algorithm - for new mutetunes design public static void OnUpdateSoundSourceInfos(SoundSourceInfo[] soundSourceInfos) { bool BgMusicHeard = false; bool NonBgMusicHeard = false; // Dictionary<int, SoundSourceInfo> ssiDict = new Dictionary<int, SoundSourceInfo>(); SoundServer.SoundSourceInfos = soundSourceInfos; //TODO: if volume was changed for mutetunes or for bg music, update the other so that they are in sync // Determine if background music and any non-background music sound is active NonBgMusicHeard = false; for (int i = 0; i < SoundServer.SoundSourceInfos.Length; i++) { SoundSourceInfo info = SoundServer.SoundSourceInfos[i]; //ssiDict[info.Pid] = info; if (!info.IsSilentRightNow()) LastTimeHeardDict[info.Pid] = DateTime.Now; if (BgMusicPids.Contains(info.Pid)) { BgMusicHeard = !info.IsSilentRightNow(); UserWantsBgMusic = true; if (!info.IsActiveInterval2()) // We use a shorter interval here than for foreground sounds for better UI responsiveness and since it is more likely that sound will be continuous UpdateMusicState(BgMusicState.Pause); // Assume it is paused if we haven't heard background music in awhile else { if (info.ChannelVolumeIsMuted()) UpdateMusicState(BgMusicState.Mute); else UpdateMusicState(BgMusicState.Play); } } else { if (info.IsActiveForAwhile() == true) NonBgMusicHeard = true; } } if ((UserWantsBgMusic)) { if ((NonBgMusicHeard == true) && (BgMusicHeard == true)) { AutoMuted = true; SmartMute(); } else if ((AutoMuted == true) && (NonBgMusicHeard == false)) { AutoMuted = false; Restore(); //TODO: Need to have this run in ui thread if it sets up the browser control } } //LatestSoundSourceInfoDict = ssiDict; }