private void ShowMediaInfoFlyout(FrameworkElement elem) { PlayListFile plf = null; if (elem != null && (plf = elem.DataContext as PlayListFile) != null) { MessengerInstance.Send <Message <DecoderTypes> >( new Message <DecoderTypes>(async(decoderType) => { int newIndex = PlayListFileSource.IndexOf(PlayListFileSource.FirstOrDefault(x => x == plf)); _RequestedDecoderType = decoderType; if (SelectedIndex != newIndex) { SelectedIndex = newIndex; } //로딩 패널 표시 MessengerInstance.Send(new Message("IsOpen", true), "ShowLoadingPanel"); await ThreadPool.RunAsync(async handler => { await DispatcherHelper.RunAsync(() => { //재생요청 RequestPlayback(false); }); }, WorkItemPriority.Normal); }) .Add("StorageItemInfo", plf) .Add("ButtonName", "CodecInformation"), "ShowMediaFileInformation"); } }
private async void RequestPlaybackWithLoadingPanel(StorageItemInfo item) { if (item != null) { //추가되는 경우가 있으므로 만일을 대비해 가장 뒤의 아이템 선택 var newIndex = PlayListFileSource.IndexOf(PlayListFileSource.LastOrDefault(x => x.Path == item.Path)); if (newIndex > -1 && newIndex < PlayListFileSource.Count) { SelectedIndex = newIndex; //로딩 패널 표시 MessengerInstance.Send(new Message("IsOpen", true), "ShowLoadingPanel"); await ThreadPool.RunAsync(async handler => { await DispatcherHelper.RunAsync(() => { //재생요청 RequestPlayback(true); }); }, WorkItemPriority.Normal); } } }
protected override void RegisterMessage() { MessengerInstance.Register <PlayList>(this, "ChangePlayList", (playList) => { CurrentPlayList = playList; }); MessengerInstance.Register <bool>(this, "ResetSelectionMode", (val) => { SelectedIndex = -1; BackNormalButtonSetTapped(null, null); }); MessengerInstance.Register <Message>(this, "PrepareLoadPlayListFile", (message) => { PreparedData = new PreparedData { //재생목록에서 지금재생중으로 이동 직전에 동기로드 카운트 설정 //지금 재생할 비디오와 다음 재생 프리뷰용으로 총 2개 SyncLoadPlayListFileCount = 2, DecoderType = message.GetValue <DecoderTypes>("DecoderType"), StorageItemInfo = message.GetValue <StorageItemInfo>("StorageItemInfo") }; }); //FileAssociation에서 이미 "지금 재생중"이 선택되어진 상태에서 넘어온다. MessengerInstance.Register <Message>(this, "SelectPlayListFile", async(message) => { BackNormalButtonSetTapped(null, null); _RequestedDecoderType = message.GetValue <DecoderTypes>("DecoderType"); var storageItemInfo = message.GetValue <StorageItemInfo>("StorageItemInfo"); var orderNo = PlayListFileSource.LastOrDefault() != null ? (int)PlayListFileSource.LastOrDefault().OrderNo : 0; //새롭게 추가된 List <PlayListFile> playListFileList = new List <PlayListFile>(); playListDAO.LoadPlayListFiles(CurrentPlayList, orderNo, (playListFile) => { //이벤트 등록 및 표시명 설정 SetPlayListFile(playListFile); //리스트에 바인딩 if (PlayListFileSource.All(x => x.Path != playListFile.Path)) { PlayListFileSource.Add(playListFile); } else if (PlayListFileSource.Any(x => x.Path == playListFile.Path && x.OrderNo != playListFile.OrderNo)) { //기존 리스트에 존재하나 순서가 변경된 경우 var tmp = PlayListFileSource.First(x => x.Path == playListFile.Path && x.OrderNo != playListFile.OrderNo); PlayListFileSource.Remove(tmp); PlayListFileSource.Add(playListFile); } //추가 정보 로드 LoadExtraInfoAsync(playListFile); }); var newIndex = PlayListFileSource.IndexOf(PlayListFileSource.LastOrDefault(x => x.Path == storageItemInfo.Path)); if (newIndex > -1 && newIndex < PlayListFileSource.Count) { SelectedIndex = newIndex; //로딩 패널 표시 MessengerInstance.Send(new Message("IsOpen", true), "ShowLoadingPanel"); await ThreadPool.RunAsync(async handler => { await DispatcherHelper.RunAsync(() => { //재생요청 RequestPlayback(true); }); }, WorkItemPriority.Normal); } }); MessengerInstance.Register <int>(this, "NextPlayListFile", (index) => { var nextIndex = SelectedIndex + index; if (nextIndex > -1 && nextIndex < PlayListFileSource.Count) { SelectedIndex = nextIndex; PlayListFileSource[SelectedIndex].PausedTime = TimeSpan.FromSeconds(0); RequestPlayback(false); } }); MessengerInstance.Register <Message>(this, "SavePlayListFile", (message) => { var file = message.GetValue <PlayListFile>(); playListDAO.UpdatePausedTime(file); //System.Diagnostics.Debug.WriteLine("PlayListViewModel : Message - SavePlayListFile =>" + file.PausedTime); }); }