public void Handle(AudioTrackEdited message) { AudioObj fromBackgroundAudio = this.GetCurrentTrackFromBackgroundAudio(); if (fromBackgroundAudio != null && message.OwnerId == fromBackgroundAudio.owner_id && message.Id == fromBackgroundAudio.id) { fromBackgroundAudio.artist = message.Artist; fromBackgroundAudio.title = message.Title; } AudioTrack track = BGAudioPlayerWrapper.Instance.Track; long? nullable1 = track != null ? new long?(track.GetTagOwnerId()) : new long?(); string str = track != null?track.GetTagId() : null; if (str != null && ((IEnumerable <char>)str).Contains <char>('_')) { str = str.Substring(str.IndexOf('_') + 1); } if (track != null) { long?nullable2 = nullable1; long valueOrDefault = nullable2.GetValueOrDefault(); if ((message.OwnerId == valueOrDefault ? (nullable2.HasValue ? 1 : 0) : 0) != 0 && message.Id.ToString() == str) { track.BeginEdit(); track.Artist = message.Artist; track.Title = message.Title; track.EndEdit(); } } this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.ArtistName)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.TrackName)); this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.CurrentTrackStr)); }
public static void PlayCurrentTrack(BackgroundAudioPlayer player, Action <bool> resultCallback = null, bool justPlay = false) { bool flag = false; try { player.Volume = 1.0; AudioTrack track = player.Track; if (track != null) { try { player.Play(); } catch (Exception ex) { if (resultCallback == null) { return; } resultCallback(false); return; } if (justPlay) { resultCallback(true); return; } } if (track != null && track.Source != null) { //track.Source; AudioTrackHelper.EnsureAppGlobalStateInitialized(); if (track.Source.OriginalString.StartsWith("http") && track.GetTagOwnerId() == AppGlobalStateManager.Current.LoggedInUserId && AppGlobalStateManager.Current.GlobalState.IsMusicCachingEnabled) { PlayedFilesInfo playedFilesInfo = new PlayedFilesInfo(); playedFilesInfo.Restore(); Uri source = track.Source; string tag = track.Tag; playedFilesInfo.Add(source, tag); } Playlist playlist = PlaylistManager.LoadTracksFromIsolatedStorage(true); AccountService.Instance.StatsTrackEvents(StatsEventsTracker.ConvertToAppEvents((IEnumerable <object>) new List <AudioPlayEvent>() { new AudioPlayEvent() { OwnerAndAudioId = track.Tag, Source = playlist.Metadata.ActionSource } }), (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(result => {})); if (resultCallback == null) { return; } flag = true; resultCallback(true); } else { if (resultCallback == null) { return; } flag = true; resultCallback(true); } } catch (Exception ex) { Logger.Instance.Error("Failed to start playing. ", ex); if (flag || resultCallback == null) { return; } resultCallback(false); } }