Esempio n. 1
0
        public void PlayTrack(Track track)
        {
            var spotifireTrack = GetSpotifireTrack(track.Link);

            session.PlayerLoad(spotifireTrack);
            session.PlayerPlay();
        }
Esempio n. 2
0
        public Track ResetAlreadyQueued(Track track, string user)
        {
            if (track == null) return null;

            track.IsAlreadyQueued = (queueManager != null && queueManager.GetAll().Any(t => t.Track.Link == track.Link));
            return track;
        }
        public string CannotQueue(Track track, string user)
        {
            if (track == null)
            {
                return "Track can no longer be found. Its music provider might be disabled.";
            }

            return string.Empty;
        }
        public string CannotQueue(Track track, string user)
        {
            if (track == null) return string.Empty;

            return musicPlayer.CurrentlyPlayingTrack != null &&
                   musicPlayer.CurrentlyPlayingTrack.Track.Name == track.Name
                       ? "Cannot queue this track as it is already playing."
                       : string.Empty;
        }
        public string CannotQueue(Track track, string user)
        {
            if (track == null) return string.Empty;

            return musicPlayer.CurrentlyPlayingTrack != null &&
                   musicPlayer.CurrentlyPlayingTrack.Track.Name == track.Name
                       ? "Cannot queue this track as it is already playing."
                       : string.Empty;
            //musicPlayer.CurrentlyPlayingTrack.Track.Album.Name == track.Album.Name; //I have found that the mappers are allowing null albums
        }
        public string CannotQueue(Track track, string user)
        {
            if (track == null) return string.Empty;

            var xHoursAgo = DateTime.Now.AddHours(-queueRuleSettings.LastXHours);
            return queuedTrackDataService.GetAll()
                       .Any(q => q.Track.Name == track.Name && q.StartedPlayingDateTime > xHoursAgo && q.User == user)
                       ? string.Format("Cannot queue a track that you queued in the last {0} hours.", queueRuleSettings.LastXHours)
                       : string.Empty;
        }
        public bool IsTrackRestricted(Track track)
        {
            if (track == null || track.Name == null) return true;
            char[] comma = {','};

            var names = searchRuleSettings.ForbiddenTrackNames.Split(comma);

            if (!names.Any() || (names.Count() == 1 && names.FirstOrDefault() == string.Empty)) return false;

            return searchRuleSettings.ForbiddenTrackNames != string.Empty &&
                   names.Any(s => track.Name.ToUpper().Contains(s.ToUpper()));
        }
        public void Check_can_queue_when_track_is_not_null()
        {
            // Arrange
            var trackToQueue = new Track
                {
                    Name = "Test Track name",
                    Album = new Album { Name = "Test Album name" }
                };
            var musicPlayer = new Mock<IMusicPlayer>();

            // Act
            var classUnderTest = new CannotQueueTrackDisabledProviderQueueRule(musicPlayer.Object);
            var result = classUnderTest.CannotQueue(trackToQueue, "Tester Test");

            // Assert
            Assert.That(result == string.Empty);
        }
Esempio n. 9
0
 public Track Map(Model.Track track, SoundCloudMusicProvider musicProvider, string user, bool mapArtists = false)
 {
     var trackLink = track.id;
     var trackResult = new Track
     {
         Link = trackLink.ToString(CultureInfo.InvariantCulture),
         Name = track.title,
         IsAvailable = track.streamable,
         Duration = new TimeSpan(0,0,0,0,track.duration),
         DurationMilliseconds = track.duration,   
         MusicProvider = musicProvider.Descriptor,
         TrackArtworkUrl = track.artwork_url ?? "content/styles/Images/soundcloud-icon.png",
         ExternalLink = new Uri(track.permalink_url)
     };
     alreadyQueuedHelper.ResetAlreadyQueued((trackResult),user);
     
     return trackResult;
 }
Esempio n. 10
0
 public Track RickRoll(Track track, string user)
 {
     logger.Trace("RickRoll");
     if((track.Artists!=null && track.Artists.Any(a => RickRollExists(a.Link))) || (track.Album !=null && RickRollExists(track.Album.Link)) || RickRollExists(track.Link))            
     {
         const string rickRollTrackId = "6JEK0CvvjDjjMUBFoXShNZ";
         var rickRollTrack = musicProviderFactory.GetMusicProviderByIdentifier(track.MusicProvider.Identifier).GetTrack(rickRollTrackId, user);
         //Create a new track that looks like the the original but is in fact 'Never give you up'
         var rickRolledTrack = new Track
                               {
                                   Link = rickRollTrack.Link,
                                   Name = track.Name,
                                   Album = track.Album,
                                   Artists = track.Artists,
                                   Duration = rickRollTrack.Duration,
                                   DurationMilliseconds = (long)rickRollTrack.Duration.TotalMilliseconds,
                                   IsAvailable = track.IsAvailable,                                          
                               };
         logger.Debug("Rick rolling track {0}", track);
         return rickRolledTrack;
     }
     return track;
 }
Esempio n. 11
0
 public void SetUp()
 {
     IList<Artist> artists = new List<Artist>();
     var artist = new Artist {Name = "test name"};
     artists.Add(artist);
     track = new Track
                 {
                     Name = "Test Track name",
                     Album = new Album {Name = "Test Album name",Artist = artist},
                     Artists = artists,
                     Duration = new TimeSpan(0,0,5,0),
                     DurationMilliseconds = 5,
                     IsAlreadyQueued = false,
                     IsAvailable = true,
                     Link = "/test",
                     MusicProvider = new MusicProviderDescriptor
                             {
                                 Name = "Spotify",
                                 Identifier = "sp"
                             },
                     Popularity = 0,
                     TrackArtworkUrl = "/test"
                 };
 }
Esempio n. 12
0
 public void PlayTrack(Track track)
 {
     var spotifireTrack = GetSpotifireTrack(track.Link);          
     session.PlayerLoad(spotifireTrack);
     session.PlayerPlay();           
 }
Esempio n. 13
0
 public IEnumerable<string> CannotQueueTrack(Track track, string user)
 {
     var errors = queueRules.Select(q => q.CannotQueue(track, user));
     return errors;
 }
 public string CannotQueue(Track track, string user)
 {
     return queueManager.GetAll().Count(q => q.User == user) >= queueRuleSettings.QueueCount
         ? string.Format("You can only queue {0} tracks at a time.", queueRuleSettings.QueueCount) : string.Empty;
 }
Esempio n. 15
0
 public void PlayTrack(Track trackToPlay)
 {
     logger.Trace("PlayTrack");
     const string prefix = "spotify:track:";
     using (var l = session.ParseLink(prefix + trackToPlay.Link))
     using (var track = l.As<ITrack>())
     {
         logger.Debug("Attempting to load track {0}", trackToPlay);
         //Load the track in the player
         var trackTask = track.Load();
         logger.Debug("Waiting for track {0} to load", trackToPlay);
         trackTask.Wait();
         logger.Debug("Track {0} was loaded", trackToPlay);
         session.PlayerLoad(track);
         logger.Debug("Track {0} was loaded by player", trackToPlay);
         session.PlayerPlay();
         logger.Debug("Track {0} is playing", trackToPlay);
     }
 }