예제 #1
0
    private void GetTrackTags()
    {
      if (CurrentTrackTag != null)
      {
        PreviousTrackTag = CurrentTrackTag;
      }

      bool isInternetStream = Util.Utils.IsAVStream(CurrentTrackFileName) && !Util.Utils.IsLastFMStream(CurrentTrackFileName);
      if (isInternetStream && _usingBassEngine)
      {
        NextTrackTag = null;
        return;
      }

      PlayListItem currentItem = PlaylistPlayer.GetCurrentItem();
      PlayListItem nextItem = PlaylistPlayer.GetNextItem();
      if (currentItem != null)
      {
        CurrentTrackTag = (MusicTag)currentItem.MusicTag;
      }
      else
      {
        CurrentTrackTag = null;
      }

      if (nextItem != null)
      {
        NextTrackTag = (MusicTag)nextItem.MusicTag;
      }
      else
      {
        NextTrackTag = null;
      }

    }
        public void InsertItemButNotStartPlayingGivesNull()
        {
            PlayListPlayer player = new PlayListPlayer();

            player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
            PlayList     playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
            PlayListItem item1    = new PlayListItem();

            playlist.Add(item1);
            Assert.IsNull(player.GetCurrentItem());
        }
예제 #3
0
        public override int RenderVisualization()
        {
            try
            {
                if (VisualizationWindow == null || !VisualizationWindow.Visible || _visParam.VisHandle == 0)
                {
                    return(0);
                }

                // Set Song information, so that the plugin can display it
                if (trackTag != null && Bass != null)
                {
                    _playlistPlayer = PlayListPlayer.SingletonPlayer;
                    PlayListItem curPlaylistItem = _playlistPlayer.GetCurrentItem();

                    _mediaInfo.Position    = (int)Bass.CurrentPosition;
                    _mediaInfo.Duration    = (int)Bass.Duration;
                    _mediaInfo.PlaylistLen = 1;
                    _mediaInfo.PlaylistPos = _playlistPlayer.CurrentPlaylistPos;
                }
                else
                {
                    _mediaInfo.Position    = 0;
                    _mediaInfo.Duration    = 0;
                    _mediaInfo.PlaylistLen = 0;
                    _mediaInfo.PlaylistPos = 0;
                }
                if (IsPreviewVisualization)
                {
                    _mediaInfo.SongTitle = "Mediaportal Preview";
                }
                BassVis.BASSVIS_SetInfo(_visParam, _mediaInfo);

                if (RenderStarted)
                {
                    return(1);
                }

                int stream = 0;

                if (Bass != null)
                {
                    stream = (int)Bass.GetCurrentVizStream();
                }

                BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
                RenderStarted = BassVis.BASSVIS_RenderChannel(_visParam, stream);
            }

            catch (Exception) {}

            return(1);
        }
        public void PlayMovesCurrentToItem()
        {
            PlayListPlayer player = new PlayListPlayer();

            player.g_Player            = this; //fake g_Player
            player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
            PlayList     playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
            PlayListItem item1    = new PlayListItem();

            playlist.Add(item1);
            player.PlayNext();
            Assert.AreEqual(item1, player.GetCurrentItem());
            Assert.IsTrue(hasPlayBeenCalled);
        }
예제 #5
0
        /// <summary>
        /// Update Playlist control items with thumbs
        /// </summary>
        /// <param name="item">Item to update</param>
        /// <param name="strThumbFile">Thumb file to use</param>
        private void UpdateListItemImage(GUIListItem item, string strThumbFile)
        {
            if (item == null)
            {
                return;
            }

            var strThumb = strThumbFile;

            item.IconImageBig = strThumb;
            item.IconImage    = strThumb;

            // let us test if there is a larger cover art image
            string strLarge = Util.Utils.ConvertToLargeCoverArt(strThumbFile);

            if (Util.Utils.FileExistsInCache(strLarge))
            {
                strThumb = strLarge;
            }
            item.ThumbnailImage = strThumb;

            var pli = _playlistPlayer.GetCurrentItem();

            //TODO: for debug and should be removed
            if (pli == null)
            {
                Log.Info("MIKE LAST.FM RADIO REWORK: pli is null?!?!?!?!");
                Log.Info("Current Song: {0}", _playlistPlayer.CurrentSong.ToString(CultureInfo.InvariantCulture));
                Log.Info("Current pos: {0}", _playlistPlayer.CurrentPlaylistPos.ToString(CultureInfo.InvariantCulture));
                Log.Info("Playlist name: {0}", _playlistPlayer.CurrentPlaylistName);
                Log.Info("Playlist Type: {0}", _playlistPlayer.CurrentPlaylistType.ToString());
                return;
            }

            if (item.Path == pli.FileName)
            {
                GUIPropertyManager.SetProperty("#Play.Current.Thumb", strThumb);
            }

            if (GUIWindowManager.ActiveWindow == GetID && PlaylistControl.SelectedListItem != null &&
                item == PlaylistControl.SelectedListItem)
            {
                GUIControl.SelectItemControl(GetID, PlaylistControl.GetID, item.ItemId);
            }
        }
예제 #6
0
        public override bool DoesPostRender()
        {
            if (!g_Player.Playing ||
                g_Player.IsVideo || g_Player.IsDVD || g_Player.IsTVRecording || g_Player.IsTV ||
                (!g_Player.IsRadio && !g_Player.IsMusic))
            {
                _fileName = string.Empty;
                OnUpdateState(false);
                return(base.IsAnimating(AnimationType.WindowClose));
            }

            if (g_Player.Playing)
            {
                if (g_Player.CurrentFile.Contains(".tsbuffer") ||
                    g_Player.CurrentFile.StartsWith("rtsp://", StringComparison.InvariantCultureIgnoreCase))
                {
                    PlayListItem pitem = playlistPlayer.GetCurrentItem();
                    if (pitem != null)
                    {
                        if (pitem.FileName != _fileName)
                        {
                            _fileName             = pitem.FileName;
                            _visualisationEnabled = false;
                        }
                    }
                    else
                    {
                        if (g_Player.CurrentFile != _fileName)
                        {
                            _fileName             = g_Player.CurrentFile;
                            _visualisationEnabled = false;
                        }
                    }
                }
                else if (g_Player.CurrentFile != _fileName)
                {
                    _fileName = g_Player.CurrentFile;
                    if (_settingVisEnabled)
                    {
                        _visualisationEnabled = true;
                    }
                }
            }

            if (GUIGraphicsContext.IsFullScreenVideo || GUIGraphicsContext.Calibrating)
            {
                OnUpdateState(false);
                return(base.IsAnimating(AnimationType.WindowClose));
            }

            if (!GUIGraphicsContext.Overlay)
            {
                OnUpdateState(false);

                if ((_videoWindow != null) &&
                    (GUIGraphicsContext.VideoWindow.Equals(new Rectangle(_videoWindow.XPosition, _videoWindow.YPosition,
                                                                         _videoWindow.Width, _videoWindow.Height))))
                {
                    return(base.IsAnimating(AnimationType.WindowClose));
                }
                else
                {
                    if ((_videoRectangle != null) &&
                        (GUIGraphicsContext.VideoWindow.Equals(new Rectangle(_videoRectangle.XPosition, _videoRectangle.YPosition,
                                                                             _videoRectangle.Width, _videoRectangle.Height))))
                    {
                        return(base.IsAnimating(AnimationType.WindowClose));
                    }
                }
                return(false);
                // no final animation when the video window has changed, this happens most likely when a new window opens
            }
            OnUpdateState(true);
            return(true);
        }
예제 #7
0
        public override int RenderVisualization()
        {
            try
            {
                if (VisualizationWindow == null || !VisualizationWindow.Visible || _visParam.VisHandle == 0)
                {
                    return(0);
                }

                // Any is wrong with PlaybackStateChanged, if the songfile automatically changed
                // so i have create a new variable which fix this problem
                if (Bass != null)
                {
                    if (Bass.CurrentFile != _OldCurrentFile && !Bass.IsRadio)
                    {
                        trackTag = TagReader.TagReader.ReadTag(Bass.CurrentFile);
                        if (trackTag != null)
                        {
                            _songTitle      = String.Format("{0} - {1}", trackTag.Artist, trackTag.Title);
                            _OldCurrentFile = Bass.CurrentFile;
                        }
                        else
                        {
                            _songTitle = "   ";
                        }
                    }

                    // Set Song information, so that the plugin can display it
                    if (trackTag != null && !Bass.IsRadio)
                    {
                        _playlistPlayer = PlayListPlayer.SingletonPlayer;
                        PlayListItem curPlaylistItem = _playlistPlayer.GetCurrentItem();

                        MusicStream streams = Bass.GetCurrentStream();
                        // Do not change this line many Plugins search for Songtitle with a number before.
                        _mediaInfo.SongFile    = Bass.CurrentFile;
                        _mediaInfo.SongTitle   = (_playlistPlayer.CurrentPlaylistPos + 1) + ". " + _songTitle;
                        _mediaInfo.Position    = (int)(1000 * Bass.CurrentPosition);
                        _mediaInfo.Duration    = (int)Bass.Duration;
                        _mediaInfo.PlaylistLen = 1;
                        _mediaInfo.PlaylistPos = _playlistPlayer.CurrentPlaylistPos;
                    }
                    else
                    {
                        if (Bass.IsRadio)
                        {
                            // Change TrackTag to StreamTag for Radio
                            trackTag = Bass.GetStreamTags();
                            if (trackTag != null)
                            {
                                // Artist and Title show better i think
                                _songTitle           = trackTag.Artist + ": " + trackTag.Title;
                                _mediaInfo.SongTitle = _songTitle;
                            }
                            else
                            {
                                _songTitle = "   ";
                            }
                            _mediaInfo.Position = (int)(1000 * Bass.CurrentPosition);
                        }
                        else
                        {
                            _mediaInfo.Position    = 0;
                            _mediaInfo.Duration    = 0;
                            _mediaInfo.PlaylistLen = 0;
                            _mediaInfo.PlaylistPos = 0;
                        }
                    }
                }

                if (IsPreviewVisualization)
                {
                    _mediaInfo.SongTitle = "Mediaportal Preview";
                }
                BassVis.BASSVIS_SetInfo(_visParam, _mediaInfo);

                if (RenderStarted)
                {
                    return(1);
                }

                int stream = 0;

                if (Bass != null)
                {
                    stream = (int)Bass.GetCurrentVizStream();
                }

                // ckeck is playing
                int nReturn = BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.IsPlaying);
                if (nReturn == Convert.ToInt32(BASSVIS_PLAYSTATE.Play) && (_visParam.VisHandle != 0))
                {
                    // Do not Render without playing
                    if (MusicPlayer.BASS.Config.MusicPlayer == AudioPlayer.WasApi)
                    {
                        RenderStarted = BassVis.BASSVIS_RenderChannel(_visParam, stream, true);
                    }
                    else
                    {
                        RenderStarted = BassVis.BASSVIS_RenderChannel(_visParam, stream, false);
                    }
                }
            }

            catch (Exception) {}

            return(1);
        }