/// <summary> /// Invoked when the search delay is hit /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void SearchDelay_Tick(object sender, EventArgs e) { searchDelay.Stop(); try { if (ysThread != null && ysThread.IsAlive) { ysThread.Abort(); } } catch (Exception exc) { U.L(LogLevel.Error, "SOUNDCLOUD", "Could not abort search thread: " + exc.Message); } ThreadStart searchThread = delegate() { Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { SearchOverlay = Visibility.Visible; })); try { ObservableCollection <TrackData> tracks = SoundCloudManager.Search(searchText); Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { //ClearSort(); ItemsSource = tracks; })); } catch (Exception exc) { U.L(LogLevel.Warning, "SoundCloud", "Could not search: " + exc.Message); } Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { SearchOverlay = Visibility.Collapsed; })); }; ysThread = new Thread(searchThread); ysThread.Name = "SoundCloud search"; ysThread.Priority = ThreadPriority.BelowNormal; ysThread.Start(); }
/// <summary> /// Fills the list with default tracks /// </summary> private void FillDefaultTracks() { try { if (ysThread != null && ysThread.IsAlive) { ysThread.Abort(); } } catch { } ThreadStart SoundCloudThread = delegate() { Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { SearchOverlay = Visibility.Visible; })); try { ObservableCollection <TrackData> tracks = SoundCloudManager.TopFeed(); Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { //ClearSort(); ItemsSource = tracks; })); } catch (Exception e) { U.L(LogLevel.Warning, "SoundCloud", "Could not populate TopRated: " + e.Message); } Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { SearchOverlay = Visibility.Collapsed; })); }; ysThread = new Thread(SoundCloudThread); ysThread.Name = "SoundCloud default"; ysThread.Priority = ThreadPriority.BelowNormal; ysThread.Start(); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; //create our soundcloud API _soundCloud = new SoundCloudManager(DisConfig.Soundcloud.Token); //create our music queue _queue = new MusicQueue(); manager.CreateCommands("", group => { //register skip command. group.CreateCommand("skip"). Parameter("nothing", ParameterType.Unparsed). Description("Skips the current song in the music queue."). Do(SkipCommand); //register request command group.CreateCommand("request"). Parameter("url", ParameterType.Required). Description("Adds youtube or soundcloud video to DiscoBot queue."). Do(RequestCommand); //register join room command group.CreateCommand("joinroom"). Parameter("room", ParameterType.Unparsed). Description("Joins a voice channel that you specified."). Do(JoinVoiceCommand); //register join room command group.CreateCommand("leaveroom"). Parameter("room", ParameterType.Unparsed). Description("Leaves any voice channel the bot is connected to in this server."). Do(LeaveVoiceCommand); }); }