private async Task LoadTracks(CancellationToken token) { OnTaskStarted("audio"); try { var response = await DataService.GetPopularTracks(SelectedGenre.Id, ForeignOnly); if (!token.IsCancellationRequested) { if (response.Items != null && response.Items.Count > 0) { Tracks = response.Items; if (AudioService.CurrentAudio == null) { AudioService.CurrentAudio = Tracks.First(); AudioService.SetCurrentPlaylist(Tracks); } } else { OnTaskError("audio", ErrorResources.LoadAudiosErrorEmpty); } } } catch (Exception ex) { LoggingService.Log(ex); OnTaskError("audio", ErrorResources.LoadAudiosErrorCommon); } OnTaskFinished("audio"); }
public void Play() { if (CurrentTrack == null) { CurrentTrack = Tracks.First(); } _playback?.Play(); }
public Uri GetNextTrack() { if (!Tracks.Any()) { return(null); } if (Repeat == RepeatMode.Song && CurrentTrack != null) { return(CurrentTrack.Uri); } if (Repeat == RepeatMode.None && CurrentTrack == Tracks.Last() && Shuffle == false) { return(null); } if (Repeat == RepeatMode.List && CurrentTrack == Tracks.Last() && Shuffle == false) { return(Tracks.First().Uri); } if ((Repeat == RepeatMode.List || Repeat == RepeatMode.None) && Shuffle == true) { return(GetRandomTrack().Uri); } if (CurrentTrack == null) { return(Tracks.First().Uri); } if (CurrentTrack != Tracks.Last()) { return(Tracks[Tracks.IndexOf(CurrentTrack) + 1].Uri); } return(null); }
private void LoadDesignData() { Tracks.Add(new Track("O que eu sempre quiz fazer mas nunca fiz", "Teste 2 Teste 2 Teste 2 Teste 2 Teste 2\n Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 Teste 2 ")); Tracks.Add(new Track("Teste", "Teste")); Tracks.Add(new Track("Arquitetura na cloud", "Teste 1")); Palestrantes.Add(new Palestrante("Elemar Jr", "http://qconsp.com/images/palestrantes/elemar-junior.jpg?1339080693")); Palestras.Add(new Palestra { Descricao = "Conteudo da palestra 1 que fala sobre alguma coisa que eu não sei mais o que escrever aqui", Horario = new DateTime(2012, 08, 4, 12, 00, 00), Nome = "Palestra 1", Track = Tracks.First() }); Palestras.Add(new Palestra { Descricao = "Conteudo da palestra 2 que fala sobre alguma coisa que eu não sei mais o que escrever aqui", Horario = new DateTime(2012, 8, 5, 15, 00, 00), Nome = "Palestra 2", Track = Tracks.Last() }); }
public void Stop() { _playback?.Stop(); CurrentTrack = Tracks.First(); }
protected override void OnPaint(PaintEventArgs e) { // Reset e.Graphics.Clear(bgColor); buttons.Clear(); int midx = Width / 2; // Richtungsangaben ermitteln var route = tt.GetRoute(routeIndex).Stations; var staIdx = route.IndexOf(station); var prev = route.ElementAtOrDefault(staIdx - 1); var next = route.ElementAtOrDefault(staIdx + 1); bool disableRight = tt.Type == TimetableType.Network && next == null; bool disableLeft = tt.Type == TimetableType.Network && prev == null; // Richtungsangaben zeichnen if (prev != null) { e.Graphics.DrawText(font, textColor, 5, 5, T._("von {0}", prev.SName)); } if (next != null) { var nextText = T._("nach {0}", next.SName); var nextSize = e.Graphics.MeasureString(font, nextText); e.Graphics.DrawText(font, textColor, Width - 5 - nextSize.Width, 5, nextText); } var leftdefaultTrack = Tracks.IndexOf(Tracks.FirstOrDefault(t => t.Name == DefaultTrackLeft.GetValue(routeIndex))); var rightdefaultTrack = Tracks.IndexOf(Tracks.FirstOrDefault(t => t.Name == DefaultTrackRight.GetValue(routeIndex))); // Netzwerk: Falls noch keine Angabe: Standardgleise setzen if (tt.Type == TimetableType.Network && Tracks.Any()) { if (disableLeft) { leftdefaultTrack = 0; } else if (leftdefaultTrack == -1) { MoveDefaultTrack(DefaultTrackLeft, Tracks.First(), 0); leftdefaultTrack = 0; } if (disableRight) { rightdefaultTrack = 0; } else if (rightdefaultTrack == -1) { MoveDefaultTrack(DefaultTrackRight, Tracks.First(), 0); rightdefaultTrack = 0; } } int y = 30; int maxIndent = 0; foreach (var track in Tracks) { var trackIndex = Tracks.IndexOf(track); // Einrückung des Gleisvorfeldes berehcnen var leftIndent = Math.Abs(leftdefaultTrack - trackIndex) * INDENT + 60; if (leftdefaultTrack == trackIndex) { leftIndent = disableLeft ? 30 : 0; } var rightIndent = Math.Abs(rightdefaultTrack - trackIndex) * INDENT + 60; if (rightdefaultTrack == trackIndex) { rightIndent = disableRight ? 30 : 0; } maxIndent = Math.Max(maxIndent, rightIndent + leftIndent); rightIndent = Width - rightIndent; // Gleiselinie zeichnen e.Graphics.DrawLine(textColor, leftIndent, y, rightIndent, y); // Gleisverbindungen zeichnen if (trackIndex < leftdefaultTrack) { e.Graphics.DrawLine(textColor, leftIndent, y, leftIndent - INDENT, y + LINE_HEIGHT); } else if (trackIndex > leftdefaultTrack) { e.Graphics.DrawLine(textColor, leftIndent, y, leftIndent - INDENT, y - LINE_HEIGHT); } if (trackIndex < rightdefaultTrack) { e.Graphics.DrawLine(textColor, rightIndent, y, rightIndent + INDENT, y + LINE_HEIGHT); } else if (trackIndex > rightdefaultTrack) { e.Graphics.DrawLine(textColor, rightIndent, y, rightIndent + INDENT, y - LINE_HEIGHT); } // Gleisnamen als Button hinzufügen var textSize = e.Graphics.MeasureString(font, track.Name); var nameBtn = new RenderBtn <Track>(track, new Point(midx - (int)(textSize.Width / 2) - 5, y - 8), new Size((int)textSize.Width + 5, 16), bgColor, track.Name, textColor); nameBtn.Click += NameBtn_Click; buttons.Add(nameBtn); // Netzwerk: Standardgleise anderer Routen gestrichelt zeichnen. if (DefaultTrackLeft.ContainsValue(track.Name) && leftdefaultTrack != trackIndex) { e.Graphics.DrawLine(dashedPen, 0, y, leftIndent, y); } if (DefaultTrackRight.ContainsValue(track.Name) && rightdefaultTrack != trackIndex) { e.Graphics.DrawLine(dashedPen, rightIndent, y, Width, y); } // Aktions-Buttons hinzufügen var btnLeft = midx + (int)(textSize.Width / 2) + 10; var deleteBtn = GetButton("X", track, btnLeft, y); deleteBtn.Click += DeleteBtn_Click; var upBtn = GetButton("▲", track, btnLeft + 20, y); upBtn.Click += UpBtn_Click; var downBtn = GetButton("▼", track, btnLeft + 40, y); downBtn.Click += DownBtn_Click; // Aktionsbuttons für Standardgleise if (trackIndex == leftdefaultTrack && !disableLeft) { var leftUpBtn = GetButton("▲", track, 10, y); leftUpBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackLeft, ((RenderBtn <Track>)s).Tag, -1); var leftDownBtn = GetButton("▼", track, 30, y); leftDownBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackLeft, ((RenderBtn <Track>)s).Tag, 1); } if (trackIndex == rightdefaultTrack && !disableRight) { var rightUpButton = GetButton("▲", track, Width - 46, y); rightUpButton.Click += (s, x) => MoveDefaultTrack(DefaultTrackRight, ((RenderBtn <Track>)s).Tag, -1); var rightDownBtn = GetButton("▼", track, Width - 26, y); rightDownBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackRight, ((RenderBtn <Track>)s).Tag, 1); } y += LINE_HEIGHT; } // Button für neue Gleise var addTrackText = T._("Neues Gleis hinzufügen"); var textWidth = (int)e.Graphics.MeasureString(font, addTrackText).Width; var addBtn = new RenderBtn <Track>(null, new Point(midx - (textWidth / 2) - 5, y - 8), new Size(textWidth + 10, 16), Colors.LightGrey, addTrackText); buttons.Add(addBtn); addBtn.Click += AddBtn_Click; var newHeight = (Tracks.Count) * LINE_HEIGHT + 50; if (newHeight > Height) { this.Height = newHeight; } else if (maxIndent > Width - 30) { Width = maxIndent + 30; } foreach (var args in buttons) { args.Draw(e.Graphics); } base.OnPaint(e); }