Example #1
0
        public OggFile GetPrevFile()
        {
            if (m_FileHeap == null)
            {
                return(null);
            }
            if (m_FileHeap.Count <= 0)
            {
                return(null);
            }
            if (m_PreviousFile == null)
            {
                return(null);
            }
            OggPlaylistFile tmp = m_CurrentFile;

            m_CurrentFile  = m_PreviousFile;
            m_PreviousFile = tmp;
            if (m_AutoUncache)
            {
                if (m_PreviousFile != null)
                {
                    m_PreviousFile.UnCacheFile();
                }
            }
            m_Position = m_FileHeap.IndexOf(m_CurrentFile);
            if (!m_CurrentFile.Cached)
            {
                m_CurrentFile.CacheFile();
            }
            return(m_CurrentFile.File);
        }
Example #2
0
 // Constructor
 public OggPlaylist()
 {
     m_FileHeap        = new ArrayList();
     m_CurrentFile     = null;
     m_Position        = 0;
     m_AutoOrder       = true;
     m_Random          = false;
     m_RandomGenerator = new Random();
     m_Repeat          = false;
 }
Example #3
0
        private bool m_Repeat; // Whether the playlist should repeat

        #endregion Fields

        #region Constructors

        // Constructor
        public OggPlaylist()
        {
            m_FileHeap = new List<OggPlaylistFile>();
            m_CurrentFile = null;
            m_Position = 0;
            m_AutoOrder = true;
            m_Random = false;
            m_RandomGenerator = new Random();
            m_Repeat = false;
        }
Example #4
0
 /// <summary>
 /// Remove a file from the Playlist
 /// </summary>
 /// <param name="Item">
 /// The <see cref="OggPlaylistFile"/> to remove
 /// </param>
 public void Remove(OggPlaylistFile Item)
 {
     if (m_FileHeap == null)
     {
         return;
     }
     m_FileHeap.Remove(Item);
     if (m_AutoOrder)
     {
         m_FileHeap.Sort();
     }
 }
Example #5
0
 /// <summary>
 /// Retrieves the next file for playback & advance the internal pointers
 /// </summary>
 /// <returns>
 /// A <see cref="OggFile"/>
 /// </returns>
 public OggFile GetNextFile()
 {
     if (m_FileHeap == null)
     {
         return(null);
     }
     if (m_FileHeap.Count <= 0)
     {
         return(null);
     }
     m_PreviousFile = m_CurrentFile;
     if (m_AutoUncache)
     {
         if (m_PreviousFile != null)
         {
             m_PreviousFile.UnCacheFile();
         }
     }
     if (m_Random)
     {
         m_Position = m_RandomGenerator.Next(m_FileHeap.Count - 1);
     }
     else
     {
         m_Position++;
         if (m_Position > m_FileHeap.Count)
         {
             if (m_Repeat)
             {
                 m_Position = 0;
             }
             else
             {
                 return(null);
             }
         }
     }
     m_CurrentFile        = (OggPlaylistFile)m_FileHeap[m_Position - 1];
     m_CurrentFile.Played = true;
     if (!m_CurrentFile.Cached)
     {
         m_CurrentFile.CacheFile();
     }
     return(m_CurrentFile.File);
 }
Example #6
0
        /// <summary>
        /// Implementation of IComparable.CompareTo interface
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            if (obj.GetType() != typeof(OggPlaylistFile))
            {
                throw new System.InvalidCastException("OggPlaylistFile:CompareTo obj not an OggPlaylistFile");
            }
            OggPlaylistFile tmp = (OggPlaylistFile)obj;

            if (tmp.OrderNum > this.OrderNum)
            {
                return(1);
            }
            if (tmp.OrderNum < this.OrderNum)
            {
                return(-1);
            }
            return(0);
        }
        static void Main(string[] args)
        {
            OggPlaylist playlist = new OggPlaylist();

            // Add the guitar sound
            OggFile guitarFile = new OggFile("GuitarSample.ogg");
            OggPlaylistFile guitarPlayList = new OggPlaylistFile(guitarFile, 0);
            playlist.Add(guitarPlayList);

            // Add the boing sound after the guitar
            OggFile boingFile = new OggFile("BoingSample.ogg");
            OggPlaylistFile boingPlayList = new OggPlaylistFile(boingFile, -1);
            playlist.Add(boingPlayList);

            OggPlayerFBN player = new OggPlayerFBN();

            // Keep playing until our playlist is empty
            while(true)
            {
                while (player.PlayerState != OggPlayerStatus.Waiting
                    && player.PlayerState != OggPlayerStatus.Stopped)
                {
                    Thread.Sleep(5);
                }

                if (playlist.GetNextFile() != null)
                {
                    playlist.CurrentFile.File.ResetFile();
                    player.SetCurrentFile(playlist.CurrentFile.File);
                    player.Play();
                }
                else
                {
                    break;
                }
            }
        }
Example #8
0
 /// <summary>
 /// Remove a file from the Playlist
 /// </summary>
 /// <param name="Item">
 /// The <see cref="OggPlaylistFile"/> to remove
 /// </param>
 public void Remove(OggPlaylistFile Item)
 {
     if (m_FileHeap==null) { return; }
     m_FileHeap.Remove(Item);
     if (m_AutoOrder) { m_FileHeap.Sort(); }
 }
Example #9
0
 public OggFile GetPrevFile()
 {
     if (m_FileHeap==null) { return null; }
     if (m_FileHeap.Count<=0) { return null; }
     if (m_PreviousFile==null) { return null; }
     OggPlaylistFile tmp = m_CurrentFile;
     m_CurrentFile = m_PreviousFile;
     m_PreviousFile = tmp;
     if (m_AutoUncache) { if (m_PreviousFile!=null) { m_PreviousFile.UnCacheFile(); } }
     m_Position = m_FileHeap.IndexOf(m_CurrentFile);
     if (!m_CurrentFile.Cached) { m_CurrentFile.CacheFile(); }
     return m_CurrentFile.File;
 }
Example #10
0
 /// <summary>
 /// Retrieves the next file for playback & advance the internal pointers
 /// </summary>
 /// <returns>
 /// A <see cref="OggFile"/>
 /// </returns>
 public OggFile GetNextFile()
 {
     if (m_FileHeap==null) { return null; }
     if (m_FileHeap.Count<=0) { return null; }
     m_PreviousFile = m_CurrentFile;
     if (m_AutoUncache) { if (m_PreviousFile!=null) { m_PreviousFile.UnCacheFile(); } }
     if (m_Random)
     {
         m_Position = m_RandomGenerator.Next(m_FileHeap.Count);
     }
     else
     {
         m_Position++;
         if (m_Position >= m_FileHeap.Count)
         {
             if (m_Repeat) { m_Position = 0; } else { return null; }
         }
     }
     m_CurrentFile = (OggPlaylistFile)m_FileHeap[m_Position];
     m_CurrentFile.Played = true;
     if (!m_CurrentFile.Cached) { m_CurrentFile.CacheFile(); }
     return m_CurrentFile.File;
 }