public override void UpdateTrackDisplay()
        {
            var item = MediaList;

            TrackDisplayList.Items.Clear();
            TotalPlayLength = 0;

            if (item != null)
            {
                foreach (Track t in item.Tracks)
                {
                    TrackDisplayList.Items.Add(t.Name).SubItems.Add(t.Duration);
                    t.PlayPosition = 0;
                    if (MediaList.Tracks.IndexOf(t) >= currentIndex)
                    {
                        this.TotalPlayLength += t.PlayLength;
                    }
                }
            }
            TimeSpan timeSpan = TimeSpan.FromMilliseconds(TotalPlayLengthLeft());
            string   answer   = string.Format("{0:D2}:{1:D2}:{2:D2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

            TotalPlayLengthDisplay.Text = answer;

            PlayControl.ToggleButtons();
        }
        public override Track RemoveTrackByName(string TrackName)
        {
#if NOT_NET4
            Track result = null;
            foreach (Track t in MediaList.Tracks)
            {
                if (t.Name.Equals(TrackName))
                {
                    result = t;
                    break;
                }
            }
#else
            var result = MediaList.Tracks.First(track => track.Name.Equals(TrackName));
#endif
            if (result == null)
            {
                throw new InvalidTrackFoundException(TrackName);
            }
            if (PlayControl.CurrentTrack != null && result.Equals(PlayControl.CurrentTrack.Value))
            {
                PlayControl.StopCurrentTrack();
                PlayControl.CurrentTrack = PlayControl.CurrentTrack.Next;
            }

            MediaList.Tracks.Remove(result);
            UpdateTrackDisplay();
            return(result);
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

#if !SWIG && NOT_NET4 && !NO_ENGINE
            this.Text += " - Engine: NET2.IrrKlang - .NET Version: " + Environment.Version.ToString();
#elif !SWIG && !NOT_NET4 && !NO_ENGINE
            this.Text += " - Engine: NET4.IrrKlang - .NET Version: " + Environment.Version.ToString();
#elif NO_ENGINE
            this.Text += " - Engine: NO ENGINE - .NET Version: " + Environment.Version.ToString();
#elif SWIG && NOT_NET4
            this.Text += " - Engine: SWIG / NET2.IrrKlang - .NET Version: " + Environment.Version.ToString();
#elif SWIG && !NOT_NET4
            this.Text += " - Engine: SWIG / NET4.IrrKlang - .NET Version: " + Environment.Version.ToString();
#endif

            try
            {
                engine = new EngineWrapper();
                //Console.WriteLine(example.My_variable);
                //Console.WriteLine(example.fact(5));
                //Console.WriteLine(example.get_time());
            }
            catch (Exception e)
            {
                Exception inner = e;
                MessageBox.Show(inner.ToString());
                while (inner.InnerException != null)
                {
                    inner = inner.InnerException;
                    MessageBox.Show(inner.ToString());
                }
                throw inner;
                //Exception ex = SwigEnginePINVOKE.SWIGPendingException.Retrieve();
                //throw ex;
            }



            //engine.LoadPlugins(Settings.PluginsPath);

            ShowMedia      = new ShowMediaCollection(engine, lvShowMedia, cmbShowList);
            StationMedia   = new StationMediaCollection(engine, lvStationMedia);
            ScheduledMedia = new ScheduledMediaCollection(engine, lvScheduledMedia);
            PlayerControl  = new PlayControl(this, engine, picPlayBtn, picStopBtn, picSkipBtn, picRecueBtn, trackBar1);
            PlaylistMedia  = new PlaylistMediaCollection(engine, lvPlaylist, lblTotalPlayLength, PlayerControl);
        }
        public uint TotalPlayLengthLeft()
        {
            uint totalPlayed = 0;

            foreach (Track t in MediaList.Tracks)
            {
                if (MediaList.Tracks.IndexOf(t) >= currentIndex)
                {
                    if (t.Equals(PlayControl.CurrentTrack.Value))
                    {
                        totalPlayed   += PlayControl.getPlayPosition();
                        t.PlayPosition = PlayControl.getPlayPosition();
                    }
                    else
                    {
                        totalPlayed += t.PlayPosition;
                    }
                }
            }
            return(this.TotalPlayLength - totalPlayed);
        }
        public void UpdateTrackSelection()
        {
            if (PlayControl.CurrentTrack == null)
            {
                return;
            }

            if (currentIndex > -1)
            {
                uint playLength   = PlayControl.getPlayLength();
                uint playPosition = PlayControl.getPlayPosition();

                /*if (TrackDisplayList.InvokeRequired)
                 * {
                 *  TrackDisplayList.Invoke(new MethodInvoker(delegate
                 *      {
                 *          TrackDisplayList.Items[currentIndex].Selected = true;
                 *          if (PlayControl.IsPlaying)
                 *          {
                 *              TimeSpan t = TimeSpan.FromMilliseconds(playLength - playPosition);
                 *              string answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds);
                 *              TrackDisplayList.Items[currentIndex].SubItems[1].Text = answer;
                 *          }
                 *      }));
                 * }
                 * else
                 * {*/
                TrackDisplayList.Items[currentIndex].Selected = true;
                if (PlayControl.IsPlaying)
                {
                    TimeSpan t      = TimeSpan.FromMilliseconds(playLength - playPosition);
                    string   answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds);
                    TrackDisplayList.Items[currentIndex].SubItems[1].Text = answer;
                }
                //}
            }
        }
 public PlaylistMediaCollection(EngineWrapper engine, ListViewEx TrackDisplayList, Label TotalPlayLengthDisplay, PlayControl PlayControl)
     : base(engine, "Playlist Media", "", TrackDisplayList, false)
 {
     this.PlayControl            = PlayControl;
     this.TotalPlayLengthDisplay = TotalPlayLengthDisplay;
     PlayControl.Playlist        = this;
     UpdateTrackDisplay();
 }