mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
Restore legacy transport controls
This commit is contained in:
committed by
Joshua "Yoshi" Askharoun
parent
fab63c3de3
commit
4686bf7b2d
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
using Microsoft.Zune.Util;
|
||||
using MicrosoftZunePlayback;
|
||||
using System;
|
||||
|
||||
namespace ZuneUI
|
||||
{
|
||||
partial class TransportControls
|
||||
{
|
||||
private void OnPlayClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!this._play.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.PlayClicks, 1);
|
||||
|
||||
if (this.Playing || this._playlistCurrent == null)
|
||||
return;
|
||||
if (this._lastKnownPlayerState != MCPlayerState.Closed)
|
||||
{
|
||||
this.SetPlayerState(PlayerState.Playing);
|
||||
this._playbackWrapper.Play();
|
||||
|
||||
if (!this.PlayingVideo || this._playlistCurrent.PlayNavigationOptions != PlayNavigationOptions.NavigateVideosToNowPlaying)
|
||||
return;
|
||||
NowPlayingLand.NavigateToLand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._playlistPending != null)
|
||||
this._playlistPending.Dispose();
|
||||
this._playlistPending = this._playlistCurrent;
|
||||
this.PlayPendingList();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPauseClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!this._pause.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.PauseClicks, 1);
|
||||
|
||||
if (!this.Playing)
|
||||
return;
|
||||
|
||||
this.SetPlayerState(PlayerState.Paused);
|
||||
this._playbackWrapper.Pause();
|
||||
}
|
||||
|
||||
private void OnStopClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!this._stop.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.StopClicks, 1);
|
||||
if (this._playlistPending != null)
|
||||
this._playlistPending.Dispose();
|
||||
this._playlistPending = null;
|
||||
if (this._playlistCurrent != null)
|
||||
this._playlistCurrent.Dispose();
|
||||
this._playlistCurrent = null;
|
||||
if (this._playerState != PlayerState.Stopped)
|
||||
{
|
||||
this.SetPlayerState(PlayerState.Stopped);
|
||||
this._playbackWrapper.Stop();
|
||||
}
|
||||
else
|
||||
this.UpdatePropertiesAndCommands();
|
||||
}
|
||||
|
||||
private void OnBackClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!this._back.Available || this._playlistCurrent == null)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.SkipBackwardClicks, 1);
|
||||
|
||||
if (this._lastKnownPosition > 50000000L || !this._playlistCurrent.CanRetreat)
|
||||
{
|
||||
this._playbackWrapper.SeekToAbsolutePosition(0L);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._playlistCurrent.Retreat();
|
||||
this.SetUriOnPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnForwardClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!this._forward.Available || this._playlistCurrent == null)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.SkipForwardClicks, 1);
|
||||
|
||||
if (this._currentTrack != null && this._currentTrack.IsVideo)
|
||||
return;
|
||||
if (this._lastKnownPlaybackTrack != null)
|
||||
this._lastKnownPlaybackTrack.OnSkip();
|
||||
if (this._playlistCurrent.CanAdvance)
|
||||
{
|
||||
this._playlistCurrent.Advance();
|
||||
this.SetUriOnPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SetPlayerState(PlayerState.Stopped);
|
||||
this._playbackWrapper.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
using Microsoft.Iris;
|
||||
using Microsoft.Zune.Playback;
|
||||
using Microsoft.Zune.Util;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using System;
|
||||
|
||||
namespace ZuneUI
|
||||
{
|
||||
partial class TransportControls
|
||||
{
|
||||
private async void OnPlayClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!_play.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.PlayClicks, 1);
|
||||
|
||||
if (Playing || _playlistCurrent == null)
|
||||
return;
|
||||
if (_player.PlaybackState != PlaybackState.None)
|
||||
{
|
||||
SetPlayerState(PlayerState.Playing);
|
||||
|
||||
if (_player != null)
|
||||
{
|
||||
await _player.ResumeAsync();
|
||||
}
|
||||
|
||||
if (!PlayingVideo || _playlistCurrent.PlayNavigationOptions != PlayNavigationOptions.NavigateVideosToNowPlaying)
|
||||
return;
|
||||
NowPlayingLand.NavigateToLand();
|
||||
}
|
||||
else
|
||||
{
|
||||
_playlistPending?.Dispose();
|
||||
_playlistPending = _playlistCurrent;
|
||||
PlayPendingList();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnPauseClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!_pause.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.PauseClicks, 1);
|
||||
|
||||
if (!Playing)
|
||||
return;
|
||||
|
||||
SetPlayerState(PlayerState.Paused);
|
||||
|
||||
if (_player != null)
|
||||
{
|
||||
await _player.PauseAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnStopClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!_stop.Available)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.StopClicks, 1);
|
||||
if (_playlistPending != null)
|
||||
_playlistPending.Dispose();
|
||||
_playlistPending = null;
|
||||
if (_playlistCurrent != null)
|
||||
_playlistCurrent.Dispose();
|
||||
_playlistCurrent = null;
|
||||
if (_playerState != PlayerState.Stopped)
|
||||
{
|
||||
SetPlayerState(PlayerState.Stopped);
|
||||
|
||||
if (_player != null)
|
||||
{
|
||||
await _player.PauseAsync();
|
||||
await _player.SeekAsync(TimeSpan.Zero);
|
||||
}
|
||||
}
|
||||
else
|
||||
UpdatePropertiesAndCommands();
|
||||
}
|
||||
|
||||
private async void OnBackClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!_back.Available || _playlistCurrent == null)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.SkipBackwardClicks, 1);
|
||||
|
||||
if (_lastKnownPosition > 50000000L || !_playlistCurrent.CanRetreat)
|
||||
{
|
||||
await _player.SeekAsync(TimeSpan.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_player != null)
|
||||
{
|
||||
// TODO: Play previous track
|
||||
//await _player.PreviousAsync();
|
||||
}
|
||||
SetUriOnPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnForwardClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!_forward.Available || _playlistCurrent == null)
|
||||
return;
|
||||
SQMLog.Log(SQMDataId.SkipForwardClicks, 1);
|
||||
|
||||
if (_currentTrack != null && _currentTrack.IsVideo)
|
||||
return;
|
||||
_lastKnownPlaybackTrack?.OnSkip();
|
||||
|
||||
if (_playlistCurrent.CanAdvance)
|
||||
{
|
||||
// TODO: Play next track
|
||||
//if (_player != null && _player.NextItems.Count > 0)
|
||||
//{
|
||||
// await _player.NextAsync();
|
||||
//}
|
||||
|
||||
SetUriOnPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPlayerState(PlayerState.Stopped);
|
||||
|
||||
if (_player != null)
|
||||
await _player.StopAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Player_CurrentItemChanged(object sender, PlaybackItem e)
|
||||
{
|
||||
// NOTE: This currently does not work. Perhaps something to do with
|
||||
// the lack of a valid media ID?
|
||||
|
||||
if (e.Track is null)
|
||||
return;
|
||||
|
||||
string title = $"[Strix] {e.Track.Name}";
|
||||
int num = e.Track.TrackNumber ?? 0;
|
||||
string album = e.Track.Album?.Name ?? string.Empty;
|
||||
|
||||
string artist = string.Empty;
|
||||
await foreach (var artistItem in e.Track.GetArtistItemsAsync(1, 0))
|
||||
artist = artistItem.Name;
|
||||
|
||||
Application.DeferredInvoke(new DeferredInvokeHandler(delegate
|
||||
{
|
||||
Microsoft.Zune.Util.Notification.ResetNowPlaying();
|
||||
Microsoft.Zune.Util.Notification.BroadcastNowPlaying(EMediaTypes.eMediaTypeAudio, album, artist, title, num, Guid.NewGuid());
|
||||
}), DeferredInvokePriority.Normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user