private SoundInfo AddSound(string sPath) { string sExt = "N/A"; string sTitle = "N/A"; string sFolder = ""; int iPosDot = sPath.LastIndexOf('.'); if (iPosDot >= 0) { sExt = sPath.Substring(iPosDot + 1); } else { iPosDot = sPath.Length; sExt = "<NONE>"; } int iPosBs = sPath.LastIndexOf('\\'); if (iPosBs >= 0) { if (iPosBs < 0) { iPosBs = -1; } sTitle = sPath.Substring(iPosBs + 1, (iPosDot - iPosBs) - 1); if (iPosBs > 0) { sFolder = sPath.Substring(0, iPosBs); } } SoundInfo snd = new SoundInfo(); snd.Path = sPath; snd.FileType = "\r\n" + sExt.ToUpper(); snd.FileTitle = sTitle; snd.sFolder = sFolder; snd.SoundState = MediaElementState.Closed; snd.Parent = m_sounds; m_sounds.Add(snd); // // // RscStore store = new RscStore(); store.CreateFolderPath("A:\\System\\AudioPlaybackAgent"); bool bPlNotExist; string sPl = store.ReadTextFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt", "", out bPlNotExist); if (sPl.Length > 0) { sPl += "\r\n"; } sPl += sFolder + "|" + sTitle + "|" + sPath; store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\Playlist.txt", sPl, true); if (bPlNotExist) { store.WriteTextFile("A:\\System\\AudioPlaybackAgent\\CurrentTrack.txt", "0", true); } // // // return(snd); }
private void RscViewer_SoundV10_Loaded(object sender, System.Windows.RoutedEventArgs e) { m_AppFrame.SetNoSleep(true); if (m_bLoaded) { return; } m_bLoaded = true; m_currentPosition.Tick += new System.EventHandler(m_currentPosition_Tick); RscPageArgsRetManager appArgsMgr = new RscPageArgsRetManager(); appInput = appArgsMgr.GetInput(csPageName); if (appInput != null) { m_AppFrame.AppTitle = appInput.CallerAppTitle; m_AppFrame.AppIconRes = appInput.CallerAppIconRes; int iIndex = 0; if (!Int32.TryParse(appInput.GetFlag(0), out iIndex)) { return; } //NOT NEEDED... /* * if( !double.TryParse( appInput.GetFlag(1), out dWidth ) ) return; * if( !double.TryParse( appInput.GetFlag(2), out dHeight ) ) return; */ m_siInPlayer = null; ClearAllSound(); for (int i = 0; i < appInput.DataCount; i++) { SoundInfo si = AddSound(appInput.GetData(i)); if (i == iIndex) { m_siInPlayer = si; } } if (m_siInPlayer != null) { DoPlay(); } //Denie to auto-reload on next start... appArgsMgr.Vipe(); } else { string sLastOk = RscRegistry.ReadString(HKEY.HKEY_CURRENT_USER, "Software\\Ressive.Hu\\RscViewer_SoundV11" , "LastOk", ""); if (sLastOk.Length > 0) { try { m_siInPlayer = null; //DO NOT!!! //ClearAllSound(); RscStore store = new RscStore(); string[] fles = RscSort.OrderBy(store.GetFileNames(sLastOk, "*.*")); foreach (string sFle in fles) { string sExt = RscStore.ExtensionOfPath(sFle); // FIX: To support Tube(HD)'s own local storage Video folder // where files are listed without extension!!! bool bInclude = (sExt == ""); string strFileGroup = RscRegFs.GetFileGroupEx(sExt); switch (strFileGroup) { case "Sound.Native": case "Video.Native": { bInclude = true; break; } } if (bInclude) { SoundInfo si = AddSound(sLastOk + "\\" + sFle); if (m_siInPlayer == null) { m_siInPlayer = si; } } } //DO NOT!!! /* * if( m_siInPlayer != null ) * { * DoPlay(); * } */ } catch (Exception) { } } } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (m_AppArgs.Waiting) { RscPageArgsRet appOutput = m_AppArgs.GetOutput(); if (appOutput != null) { switch (appOutput.ID) { case "SndFldrPath": if (appOutput.GetFlag(0) == "Ok") { string sFolderIn = appOutput.GetData(0); m_siInPlayer = null; ClearAllSound(); RscStore store = new RscStore(); string[] fles = RscSort.OrderBy(store.GetFileNames(sFolderIn, "*.*")); foreach (string sFle in fles) { string sExt = RscStore.ExtensionOfPath(sFle); // FIX: To support Tube(HD)'s own local storage Video folder // where files are listed without extension!!! bool bInclude = (sExt == ""); string strFileGroup = RscRegFs.GetFileGroupEx(sExt); switch (strFileGroup) { case "Sound.Native": case "Video.Native": { bInclude = true; break; } } if (bInclude) { SoundInfo si = AddSound(sFolderIn + "\\" + sFle); if (m_siInPlayer == null) { m_siInPlayer = si; } } } if (m_siInPlayer != null) { DoPlay(); } RscRegistry.WriteString(HKEY.HKEY_CURRENT_USER, "Software\\Ressive.Hu\\RscViewer_SoundV11" , "LastOk", sFolderIn); } else { //NOP... } break; } } m_AppArgs.Clear(); } }
/* * private void ContentPanel_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e) * { * bool bNoChng = (m_sContentPanel.Width == e.NewSize.Width && m_sContentPanel.Height == e.NewSize.Height); * m_sContentPanel = e.NewSize; * * if( !bNoChng ) * { * if( e.NewSize.Width < e.NewSize.Height ) * imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_portrait.jpg"); * else * imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_landscape.jpg"); * } * } */ private void Instance_PlayStateChanged(object sender, EventArgs e) { switch (BackgroundAudioPlayer.Instance.PlayerState) { case PlayState.Playing: { m_AppFrame.StatusText = "Playing..."; m_currentPosition.Stop(); m_txtSnd.Text = BackgroundAudioPlayer.Instance.Track.Title; m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")"; m_btnPlayPause.Image.Source = m_isPause; m_btnPlayPause.Visibility = Rsc.Visible; m_btnExtOpen.Visibility = Rsc.Visible; m_btnStop.Visibility = Rsc.Visible; string sTag = BackgroundAudioPlayer.Instance.Track.Tag; if (sTag.Length > 0) { int iTag = 0; if (Int32.TryParse(sTag, out iTag)) { //ATT: Can happen... if ((iTag >= 0) && (iTag < m_sounds.Count)) { try { //m_txtSnd.Text += " " + iTag.ToString(); m_siInPlayer = m_sounds[iTag]; m_btnPrev.Visibility = Rsc.ConditionalVisibility(iTag > 0); m_btnNext.Visibility = Rsc.Visible; //Allowe to restart list... //Rsc.ConditionalVisibility( idx < (m_sounds.Count - 1) ); prsBarLen.Minimum = 0; prsBarLen.Maximum = (int)BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds; m_siInPlayer.sLen = RscUtils.toDurationStr(BackgroundAudioPlayer.Instance.Track.Duration); //Refresh... lbSounds.ItemsSource = null; lbSounds.ItemsSource = m_sounds; m_currentPosition.Start(); } catch (Exception) { //NOP... } } } } break; } case PlayState.Paused: { m_AppFrame.StatusText = "Paused..."; m_currentPosition.Stop(); m_txtSnd.Text = BackgroundAudioPlayer.Instance.Track.Title; m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")"; m_btnPlayPause.Image.Source = m_isPlay; m_btnPlayPause.Visibility = Rsc.Visible; m_btnExtOpen.Visibility = Rsc.Visible; m_btnStop.Visibility = Rsc.Visible; break; } case PlayState.Stopped: { m_AppFrame.StatusText = "Stopped..."; m_currentPosition.Stop(); m_txtSnd.Text = BackgroundAudioPlayer.Instance.Track.Title; m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")"; m_btnPlayPause.Image.Source = m_isPlay; m_btnPlayPause.Visibility = Rsc.Visible; m_btnExtOpen.Visibility = Rsc.Collapsed; m_btnStop.Visibility = Rsc.Collapsed; prsBarLen.Value = 0; break; } default: { m_txtSnd.Text = "Loading..."; //BackgroundAudioPlayer.Instance.PlayerState.ToString(); break; } } }