예제 #1
0
 public void AddTrack()
 {
     if (this._addingTrack)
     {
         return;
     }
     this._addingTrack = true;
     this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.CanAddOpacity));
     try
     {
         List <AudioObj> tracks = PlaylistManager.LoadTracksFromIsolatedStorage(true).Tracks;
         AudioTrack      bTrack = BGAudioPlayerWrapper.Instance.Track;
         if (bTrack == null)
         {
             return;
         }
         AudioObj current = tracks.FirstOrDefault <AudioObj>((Func <AudioObj, bool>)(t => t.UniqueId == bTrack.GetTagId()));
         this.SetInProgress(true, "");
         AudioService.Instance.AddAudio(current.owner_id, current.aid, (Action <BackendResult <long, ResultCode> >)(res =>
         {
             this.SetInProgress(false, "");
             this._addingTrack = false;
             this.NotifyPropertyChanged <double>((Expression <Func <double> >)(() => this.CanAddOpacity));
             if (res.ResultCode != ResultCode.Succeeded)
             {
                 return;
             }
             AudioPlayerViewModel._addedTracks.Add(current.UniqueId);
             AudioObj audioObj = StreamUtils.CloneThroughSerialize <AudioObj>(current);
             audioObj.owner_id = AppGlobalStateManager.Current.LoggedInUserId;
             audioObj.aid      = res.ResultData;
             this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanAddTrack));
             this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.AddedVisibility));
             this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.CanAddVisibility));
             EventAggregator.Current.Publish((object)new AudioTrackAddedRemoved()
             {
                 Added = true,
                 Audio = audioObj
             });
         }));
     }
     catch (Exception ex)
     {
         Logger.Instance.Error("Failed to add track", ex);
     }
 }