/// <summary> /// Manages this instance. /// </summary> private void Manage() { while (doMange) { Thread.CurrentThread.Join(1); Action a; if (null != (a = managerQueue.RawDequeue())) { a(); } if (null != CurrentTrack && (CurrentTrack.Length.TotalMilliseconds - CurrentTrack.CurrentPositionMillisecond) <= PlayNextThreshold.Value) { var pre = 0; DoTheNextOne(ref pre); } if (PlayingState.Playing != State || DateTime.Now - LastProgress < progressUpdateInterval || null == CurrentTrack) { continue; } SendProgress(); } if (null == CurrentTrack) { return; } CurrentTrack.Dispose(); CurrentTrack.Stop(); }
public TrackInformationWindow(PlayableBase track) { this.CurrentTrack = track; InitializeComponent(); if (!CurrentTrack.IsOpened) { CurrentTrack.Load(); if (CurrentTrack.Image == null) { CurrentTrack.ImageLoadedComplete += (s, e) => { if (CurrentTrack.Image != null) { Dispatcher.Invoke(() => image = CurrentTrack.Image.Clone()); } }; return; } } if (CurrentTrack.Image != null) { image = CurrentTrack.Image.Clone(); } }
private void OnAboutToFinish(IntPtr player) { // HACK: ugly workaround for GStreamer's bug http://bugzilla.gnome.org/722769 // long story short, AboutToFinish signal firing twice for the same play of the same track // causes problems when Gapless Enabled because of RequestNextTrack event being fired twice if (about_to_finish_time_stamp == CurrentTrackTimeStamp) { return; } about_to_finish_time_stamp = CurrentTrackTimeStamp; // This is needed to make Shuffle-by-* work. // Shuffle-by-* uses the LastPlayed field to determine what track in the grouping to play next. // Therefore, we need to update this before requesting the next track. // // This will be overridden by IncrementLastPlayed () called by // PlaybackControllerService's EndOfStream handler. CurrentTrack.UpdateLastPlayed(); next_track_set.Reset(); pending_uri = null; next_track_pending = true; OnEventChanged(PlayerEvent.RequestNextTrack); // Gapless playback with Playbin2 requires that the about-to-finish callback does not return until // the next uri has been set. Block here for a second or until the RequestNextTrack event has // finished triggering. if (!next_track_set.WaitOne(1000, false)) { Log.Debug("[Gapless] Timed out while waiting for next_track_set to be raised"); next_track_set.Set(); } }
private void OnEos() { if (!next_track_pending && (!GaplessEnabled || (CurrentTrack != null && CurrentTrack.HasAttribute(TrackMediaAttributes.VideoStream)))) { // We don't request next track in OnEoS if gapless playback is enabled and current track has no video stream contained. // The request next track is already called in OnAboutToFinish(). OnEventChanged(PlayerEvent.RequestNextTrack); } else if (pending_uri != null) { Log.Warning("[Gapless] EOS signalled while waiting for next track. This means that Banshee " + "was too slow at calculating what track to play next. " + "If this happens frequently, please file a bug"); OnStateChanged(PlayerState.Loading); OpenUri(pending_uri, pending_maybe_video); Play(); pending_uri = null; } else if (!GaplessEnabled || (CurrentTrack != null && CurrentTrack.HasAttribute(TrackMediaAttributes.VideoStream))) { // This should be unreachable - the RequestNextTrack event is delegated to the main thread // and so blocks the bus callback from delivering the EOS message. // // Playback should continue as normal from here, when the RequestNextTrack message gets handled. Log.Warning("[Gapless] EndOfStream message received before the next track has been set. " + "If this happens frequently, please file a bug"); } else { Log.Debug("[Gapless] Reach the last music under repeat off mode"); } }
private void RegisterNoteItems() { TrackNameBox.Text = CurrentTrack.TrackName; TrackLevelBox.Text = CurrentTrack.TrackLevel.ToString(); TrackBPMBox.Text = CurrentTrack.TrackBPM.ToString(); TrackNPSBox.Text = CurrentTrack.TrackNPB.ToString(); TrackLengthBox.Text = CurrentTrack.TrackLength.ToString(); UPS.ItemsSource = CurrentTrack.GetNotes(Keys.S, Direction.UP); UPD.ItemsSource = CurrentTrack.GetNotes(Keys.D, Direction.UP); UPF.ItemsSource = CurrentTrack.GetNotes(Keys.F, Direction.UP); UPSPACE.ItemsSource = CurrentTrack.GetNotes(Keys.SPACE, Direction.UP); UPJ.ItemsSource = CurrentTrack.GetNotes(Keys.J, Direction.UP); UPK.ItemsSource = CurrentTrack.GetNotes(Keys.K, Direction.UP); UPL.ItemsSource = CurrentTrack.GetNotes(Keys.L, Direction.UP); UpScroll.ScrollToBottom(); DOWNS.ItemsSource = CurrentTrack.GetNotes(Keys.S, Direction.DOWN); DOWND.ItemsSource = CurrentTrack.GetNotes(Keys.D, Direction.DOWN); DOWNF.ItemsSource = CurrentTrack.GetNotes(Keys.F, Direction.DOWN); DOWNSPACE.ItemsSource = CurrentTrack.GetNotes(Keys.SPACE, Direction.DOWN); DOWNJ.ItemsSource = CurrentTrack.GetNotes(Keys.J, Direction.DOWN); DOWNK.ItemsSource = CurrentTrack.GetNotes(Keys.K, Direction.DOWN); DOWNL.ItemsSource = CurrentTrack.GetNotes(Keys.L, Direction.DOWN); UpdateTitle(false); }
public IHttpActionResult PutCurrentTrack(int id, CurrentTrack currentTrack) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != currentTrack.Id) { return(BadRequest()); } db.Entry(currentTrack).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CurrentTrackExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Play(Track track) { if (CurrentTrack.Equals(track)) { if (!mediaPlayer.IsPlaying) { mediaPlayer.Resume(); } } else { CurrentTrack = track; mediaPlayer.StartPlayer(track.FilePath); mediaPlayer.Resume(); mediaPlayer.Completion += delegate { var index = Tracks.IndexOf(CurrentTrack); if (++index >= Tracks.Count) { index = 0; } if (index == 0 && RepeatTracks) { Play(Tracks[index]); } else if (index > 0) { Play(Tracks[index]); } }; } }
/// <summary> /// Pushes a track between the current asynchronously. /// </summary> /// <param name="track">the track to push between the current</param> /// <param name="push"> /// a value indicating whether the track should only played when a track is playing currently. /// </param> /// <remarks> /// Note: This feature is experimental. This will stop playing the current track and /// start playing the specified <paramref name="track"/> after the track is finished the /// track will restart at the stopped position. This can be useful for example /// soundboards (playing an air-horn or something). /// </remarks> /// <returns> /// a task that represents the asynchronous operation. The task result is a value /// indicating whether the track was pushed between the current ( <see /// langword="true"/>) or the specified track was simply started ( <see /// langword="false"/>), because there is no track playing. /// </returns> public virtual async Task <bool> PushTrackAsync(LavalinkTrack track, bool push = false) { Console.WriteLine(State.ToString()); // star track immediately if (State == PlayerState.NotPlaying) { if (push) { return(false); } await PlayAsync(track, enqueue : false); return(false); } // create clone and set starting position var oldTrack = CurrentTrack.WithPosition(TrackPosition); this.noSkip = true; await PlayAsync(track, enqueue : false); // enqueue old track with starting position await PlayTopAsync(oldTrack); return(true); }
public void Stop() { Pause(); CurrentTrack.Reset(); UpdateClippingRegion(); ElapsedTime = 0; }
public virtual void Play(KeyType key, bool forceReset = true) { if (IsDisposed) { return; } IsPlaying = true; if (CurrentTrack == null || !CurrentKey.Equals(key)) { CurrentKey = key; CurrentTrack = Tracks[CurrentKey]; ElapsedTime = 0; if (forceReset) { CurrentTrack.Reset(); } UpdateClippingRegion(); } else if (forceReset) { ElapsedTime = 0; CurrentTrack.Reset(); UpdateClippingRegion(); } }
private void Note_LeftButtonDown(object sender, MouseButtonEventArgs e) { var BoxItem = (sender as ListBoxItem); var item = BoxItem.Content as Note; if (item.isActive) { return; } var notelist = CurrentTrack.GetNotesRef(item.Key, item.Direction); var index = CurrentTrack.GetNotesRef(item.Key, item.Direction).IndexOf(item); var newNote = new Note(item.Key, item.Direction) { Position = index, isActive = true }; notelist[index] = newNote; UpdateTitle(true); e.Handled = true; }
/// <summary> /// Pushes a track between the current asynchronously. /// </summary> /// <param name="track">the track to push between the current</param> /// <param name="push"> /// a value indicating whether the track should only played when a track is playing currently. /// </param> /// <remarks> /// Note: This feature is experimental. This will stop playing the current track and /// start playing the specified <paramref name="track"/> after the track is finished the /// track will restart at the stopped position. This can be useful for example /// soundboards (playing an air-horn or something). /// </remarks> /// <returns> /// a task that represents the asynchronous operation. The task result is a value /// indicating whether the track was pushed between the current ( <see /// langword="true"/>) or the specified track was simply started ( <see /// langword="false"/>), because there is no track playing. /// </returns> public virtual async Task <bool> PushTrackAsync(LavalinkTrack track, bool push = false) { // star track immediately if (State == PlayerState.NotPlaying) { if (push) { return(false); } await PlayAsync(track, enqueue : false); return(false); } // create clone and set starting position var oldTrack = CurrentTrack.WithPosition(TrackPosition); // enqueue old track with starting position Queue.Add(oldTrack); // push track await PlayAsync(track, enqueue : false); return(true); }
void OnAboutToFinish(object o, Gst.GLib.SignalArgs args) { // HACK: ugly workaround for GStreamer's bug http://bugzilla.gnome.org/722769 // long story short, AboutToFinish signal firing twice for the same play of the same track // causes problems when Gapless Enabled because of RequestNextTrack event being fired twice if (about_to_finish_time_stamp == CurrentTrackTimeStamp) { return; } about_to_finish_time_stamp = CurrentTrackTimeStamp; // This is needed to make Shuffle-by-* work. // Shuffle-by-* uses the LastPlayed field to determine what track in the grouping to play next. // Therefore, we need to update this before requesting the next track. // // This will be overridden by IncrementLastPlayed () called by // PlaybackControllerService's EndOfStream handler. CurrentTrack.UpdateLastPlayed(); next_track_set.Reset(); OnEventChanged(PlayerEvent.RequestNextTrack); if (!next_track_set.WaitOne(1000, false)) { Log.Warning("[Gapless]: Timed out while waiting for next track to be set."); next_track_set.Set(); } }
public static String GenerateHashTrack(CurrentTrack incomingTrack) { if (incomingTrack != null) return GetHashString (incomingTrack.title + incomingTrack.album + incomingTrack.artist + Convert.ToString (incomingTrack.duration)); else return null; }
public void IncrementLastPlayed(double completed) { if (!incremented_last_played && CurrentTrack != null && CurrentTrack.PlaybackError == StreamPlaybackError.None) { CurrentTrack.OnPlaybackFinished(completed); incremented_last_played = true; } }
/// <summary> /// Stop playing the current track and pause at the current position. /// </summary> /// <param name="requestedByUser"> /// Whether the request to stop was issued by the user rather than internally. /// Specifying <c>true</c> will ensure that other methods like <see cref="EnsurePlayingSomething"/> /// will not resume music playback until the next explicit call to <see cref="Play"/>. /// </param> public void Stop(bool requestedByUser = false) { UserPauseRequested |= requestedByUser; if (CurrentTrack.IsRunning) { CurrentTrack.Stop(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { CurrentTrack.Dispose(); Player = null; } }
public async Task Initialize(OAuthService oAuthService, ITurnContext ctx) { _oauthService = oAuthService; _turnContext = ctx; _currentTrack = await GetCurrentTrackObject(_oauthService.AccessToken); var currentTrackTimer = new Timer(OnCurrentTrackTimerElapsed, null, 2000, 2000); }
private void PlayTrack() { Play.IsEnabled = false; Play.Content = "Playing..."; Pause.IsEnabled = true; Pause.Content = "Pause"; CurrentTrack.Play(); }
private void StopTrack() { Play.IsEnabled = true; Pause.IsEnabled = false; Play.Content = "Play"; Pause.Content = "Stopped"; CurrentTrack.Stop(); }
private void PauseTrack() { Play.IsEnabled = true; Play.Content = "Play"; Pause.IsEnabled = false; Pause.Content = "Paused..."; CurrentTrack.Pause(); }
public MainForm() { InitializeComponent(); timer = new Timer(); timer.Tick += Timer_Tick; timer.Interval = 500; track = new CurrentTrack(); StopWork.Enabled = false; }
/// <summary> /// Method to simulate departing from station /// </summary> /// <param name="releaseTrack"> If false will leave station without releasing exit track. /// False should be used only by station manager. </param> public void DepartFromStation(Boolean releaseTrack = true) { Thread.Sleep(Station.arrivalTime); if (releaseTrack) { CurrentTrack.Free(); } station.Trains.Remove(this); TrainStatus = Status.Departed; }
public Track GetTrack() { if (!CurrentTrack.IsNormal()) { return(CurrentTrack); } ExternalAPI.Instance.UpdateTrack(CurrentTrack); return(CurrentTrack); }
public void KickTrack() { CurrentTrack.Unload(); CurrentTrack = null; SoundSource = null; OnPropertyChanged("TrackLength"); OnPropertyChanged("CurrentTrackLength"); OnPropertyChanged("Position"); OnPropertyChanged("CurrentTrackPosition"); CurrentStateChanged(); }
public async Task <Track> GetTrack() { if (!CurrentTrack.IsNormal()) { return(CurrentTrack); } await ExternalAPI.Instance.UpdateTrack(CurrentTrack); return(CurrentTrack); }
public IHttpActionResult GetCurrentTrack(int id) { CurrentTrack currentTrack = db.CurrentTracks.Find(id); if (currentTrack == null) { return(NotFound()); } return(Ok(currentTrack)); }
public static String GenerateHashTrack(CurrentTrack incomingTrack) { if (incomingTrack != null) { return(GetHashString(incomingTrack.title + incomingTrack.album + incomingTrack.artist + Convert.ToString(incomingTrack.duration))); } else { return(null); } }
public void SeekTo(double position) { seekDelegate?.Cancel(); seekDelegate = Schedule(() => { if (!beatmap.Disabled) { CurrentTrack.Seek(position); } }); }
public bool MoveFadeIn(long samples) { if (!CurrentTrack.CanMoveFadeInBy(samples)) { return(false); } CurrentTrack.MoveFadeInBy(samples); TriggerCanMoveFadeInPropertiesChanged(); ZoomToCurrentTrackStart(); return(true); }
private void SaveWithoutDialog(object sender, RoutedEventArgs e) { if (LastFilePath.Equals("")) { SaveWithDialog(sender, e); } else { CurrentTrack.SaveTrack(LastFilePath); UpdateTitle(false); } }