Example #1
0
        /// <summary>
        /// Begins playback or pauses playback
        /// </summary>
        /// <param name="entry">The playlist entry to play. Pass null to play from start</param>
        public void PlayOrPause(PlayListEntry entry)
        {
            //if we have an entry, then stop play back
            if (entry != null && GetIsPlaying())
            {
                //stop playback
                Stop();
            }

            //if the track is playing, then pressing play again will pause the track
            if (GetIsPlaying())
            {
                //its playing: pause or unpause
                Pause();
            }
            else
            {
                if (entry != null)
                {
                    //set playlist index to playing entry
                    PlayListIndex = NowPlaying.IndexOf(entry);

                    //add the entry to the history
                    AddToHistory(entry);
                }

                //run playback
                Run(entry);
            }
        }
Example #2
0
        public void GetLastHour()
        {
            Parser     p          = new Parser("kndd");
            NowPlaying nowPlaying = p.GetLastHour(out string response);

            Console.WriteLine(response);
        }
Example #3
0
            internal void Copy(NowPlaying src)
            {
                SeekPosition = src.SeekPosition;
                Length       = src.Length;
                if (OneLine == null || src.OneLine == null)
                {
                    OneLine = src.OneLine;
                }
                else
                {
                    OneLine.Copy(src.OneLine);
                }
                if (TwoLine == null || src.TwoLine == null)
                {
                    TwoLine = src.TwoLine;
                }
                else
                {
                    TwoLine.Copy(src.TwoLine);
                }
                if (ThreeLine == null || src.ThreeLine == null)
                {
                    ThreeLine = src.ThreeLine;
                }
                else
                {
                    ThreeLine.Copy(src.ThreeLine);
                }

                ImageKey = src.ImageKey;
            }
Example #4
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            NowPlaying nowPlaying = (NowPlaying)value;
            const int  maxArtists = 2;

            string[] artists = nowPlaying.Artist.Split(',');
            string   artist;

            if (artists.Length > maxArtists)
            {
                int    remainingArtists = artists.Length - maxArtists;
                string otherString      = remainingArtists == 1 ? "other" : "others";
                artist = $"{artists[0].Trim()}, {artists[1].Trim()} and {remainingArtists} {otherString}";
            }
            else
            {
                artist = nowPlaying.Artist;
            }
            string album    = System.Net.WebUtility.HtmlDecode(nowPlaying.Album);
            string fromLine = $"from {album}";

            if (!string.IsNullOrEmpty(artist))
            {
                return($"by {artist} {fromLine}");
            }
            else
            {
                return(fromLine);
            }
        }
Example #5
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        oXbmc = new XBMC_Communicator();
        oXbmc.SetIp("10.0.0.5");
        oXbmc.SetConnectionTimeout(4000);
        oXbmc.SetCredentials("", "");
        oXbmc.Status.StartHeartBeat();

        Build();

        this.AllowStaticAccess();

        //Create objects used
        oPlaylist     = new Playlist(this);
        oControls     = new Controls(this);
        oMenuItems    = new MenuItems(this);
        oContextMenu  = new ContextMenu(this);
        oShareBrowser = new ShareBrowser(this);
        oTrayicon     = new SysTrayIcon(this);
        oStatusUpdate = new StatusUpdate(this);
        oMediaInfo    = new MediaInfo(this);
        oNowPlaying   = new NowPlaying(this);
        oGuiConfig    = new GuiConfig(this);

        nbDataContainer.CurrentPage = 0;
    }
Example #6
0
        /// <summary>
        /// Clear the now playing list
        /// </summary>
        public void ClearNowPlaying()
        {
            NowPlaying.Clear();

            //stop playback
            Stop();
        }
Example #7
0
        public void GetIdtd()
        {
            string     value = "ACTION is playing [https://osu.ppy.sh/b/2129143 Nashimoto Ui - AaAaAaAAaAaAAa [aAaAaaAaAaaA]] +Hidden +DoubleTime";
            NowPlaying np    = new NowPlaying();

            NowPlayingParser.GetSongId(np, value);
            Assert.AreEqual(2129143, np.Id);
        }
Example #8
0
        public void GetIdMania()
        {
            string     value = "ACTION is playing [https://osu.ppy.sh/b/1582621 Cranky - Chandelier - King [Royal]] <osu!mania> +Hidden +DoubleTime |7K|";
            NowPlaying np    = new NowPlaying();

            NowPlayingParser.GetSongId(np, value);
            Assert.AreEqual(1582621, np.Id);
        }
Example #9
0
        public void GetIdTaiko()
        {
            string     value = "ACTION is playing [https://osu.ppy.sh/b/1921936 xi remixed by cosMo@bousouP - FREEDOM DiVE [METAL DIMENSIONS] [Hyper]] <Taiko> +Hidden +HardRock";
            NowPlaying np    = new NowPlaying();

            NowPlayingParser.GetSongId(np, value);
            Assert.AreEqual(1921936, np.Id);
        }
Example #10
0
 /// <summary>
 /// Обновява базата данни.
 /// </summary>
 public static void RefreshDataBase()
 {
     NowPlaying.OnPropertyChanged("Songs");
     MySongs.OnPropertyChanged("Bands");
     MySongs.OnPropertyChanged("Albums");
     MySongs.OnPropertyChanged("Songs");
     PlayList.OnPropertyChanged("PlayList");
 }
Example #11
0
 private bool ContextSupported(NowPlaying np)
 {
     if (np.Context == null)
     {
         return(false);
     }
     return(SupportedSpotifyContexts.Any(c => c == np.Context.Type));
 }
Example #12
0
 private async Task PlayFromOffset(
     string userId,
     Station station,
     NowPlaying ownerNP,
     StationServiceResult result,
     TimeSpan error = default)
 {
     if (error.Equals(default))
Example #13
0
        public void GetIdCatch()
        {
            string     value = "ACTION is playing [https://osu.ppy.sh/b/1599005 Co shu Nie - asphyxia (TV edit) [Ascendance & Spec's Nightmare]] <CatchTheBeat> +Hidden +DoubleTime";
            NowPlaying np    = new NowPlaying();

            NowPlayingParser.GetSongId(np, value);
            Assert.AreEqual(1599005, np.Id);
        }
        //public async Task EnsureNextVideoMatchesConditionsAsync(bool skipping) {
        //    int QueuePos = skipping ? 0 : 1;
        //    if (nextVideo != null && PlayMode == PlayerMode.Normal) {
        //        // Get new conditions
        //        GetConditionsEventArgs Args = new GetConditionsEventArgs(FilterSettings);
        //        Args.QueuePos = QueuePos;
        //        if (GetConditions != null)
        //            GetConditions(this, Args);

        //        // Run the conditions on the next video in the playlist
        //        if (!PlayerAccess.VideoMatchesConditions(nextVideo, FilterSettings.Update(playedVideos, Settings.SavedFile.AutoDownload))) {
        //            // If next video doesn't match conditions, select another one
        //            await SelectNextVideoAsync(QueuePos);
        //        }
        //    } else if (nextVideo == null)
        //        await SelectNextVideoAsync(QueuePos);
        //}

        public void ReloadVideoInfo()
        {
            if (player.CurrentVideo != null)
            {
                player.CurrentVideo = PlayerAccess.GetVideoById(player.CurrentVideo.MediaId);
                Application.Current.Dispatcher.Invoke(() => NowPlaying?.Invoke(this, new NowPlayingEventArgs(true)));
            }
        }
 public ListingsController(
     SearchByName searchByNameQuery,
     ChannelIcon channelIconQuery,
     NowPlaying nowPlayingQuery)
 {
     _searchByNameQuery = searchByNameQuery;
     _channelIconQuery = channelIconQuery;
     _nowPlayingQuery = nowPlayingQuery;
 }
Example #16
0
        private void PlaySong(ChannelHandler channel, Song song)
        {
            LogTo.Debug("[{0}] Playing song {1}", channel.Name, song.track.Name);

            var nowplaying = new NowPlaying {
                songID = song.SongID, votetime = Time.Timestamp()
            };

            Publish(string.Format("/{0}/nowplaying", channel.Name), JsonConvert.SerializeObject(nowplaying), true);
        }
Example #17
0
 public void KeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.P && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
     {
         NowPlaying.PlayPause();
     }
     else if (e.Key == Key.E && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
     {
         NavigationBar.StartSearch();
     }
 }
Example #18
0
        public bool Stop()
        {
            var result = BassActor.Stop();

            if (result)
            {
                CurrentLibraryItem = NowPlaying.Current().Value;
                PlaybackState      = PlaybackState.Stopped;
            }
            return(result);
        }
Example #19
0
        public async Task PlayNextAsync_Should_Call_Repository()
        {
            var expected = new NowPlaying();

            _nowPlayingRepository.Setup(repository => repository.PlayNextAsync()).ReturnsAsync(expected);

            var actual = await _playerService.PlayNextAsync().ConfigureAwait(false);

            _nowPlayingRepository.Verify(repository => repository.PlayNextAsync(), Times.Once);
            Assert.Equal(expected, actual);
        }
Example #20
0
        /// <summary>
        /// Removes an entry from the playlist
        /// </summary>
        /// <param name="entry"></param>
        public void RemoveFromNowPlaying(PlayListEntry entry)
        {
            //remove
            NowPlaying.Remove(entry);

            if (entry == _playingEntry)
            {
                //stop playing
                Stop();
            }
        }
Example #21
0
        private async void GetUpComingMovie(float id)
        {
            // GridMoviesDetail.IsVisible = false;

            try
            {
                SLLoader.IsVisible = true;

                //  HttpClient client = new HttpClient();
                // var response =
                //    await client.GetStringAsync("http://cinemo.azurewebsites.net/api/NowPlayingMovies/" + id);
                // var movies = JsonConvert.DeserializeObject<NowPlaying>(response);
                var movies = new NowPlaying
                {
                    Cast          = "Sjava",
                    Description   = "A young African-American visits his white girlfriend's parents for the weekend, where his simmering uneasiness about their reception of him eventually reaches a boiling point.",
                    Duration      = "05:01 Minutes",
                    Logo          = "~/Content/NowPlayingMovies/Blade_Runner_2049_poster.png",
                    LogoFile      = "Bladeposter.png",
                    MovieId       = 5,
                    MovieLanguage = "R & B",
                    MovieName     = "Umphako",
                    MoviePrint    = "1",
                    MovieType     = "Horror, Mystery, Thriller",
                    RatedPGI      = "PG 13",
                    ShowTime      = "2019-01-01 17:00",
                    TicketPrice   = "1",
                    TrailorLink   = "https://www.youtube.com/embed/DzfpyUB60YY"
                };

                LblMovieName.Text = movies.MovieName;
                LblType.Text      = movies.MovieType;

                LblPrice.Text              = "$" + movies.TicketPrice;
                LblLanguage.Text           = movies.MovieLanguage;
                LblDescription.Text        = movies.Description;
                ImgDetail.Source           = "Bladeposter.png";
                trailorUrl                 = movies.TrailorLink;
                GridMoviesDetail.IsVisible = true;
            }
            catch (Exception e)
            {
                SLLoader.IsVisible = false;

                throw;
            }
            finally
            {
                SLLoader.IsVisible = false;
            }
        }
Example #22
0
        public NowPlayingHandler(AuthPair auth, string channelName) : base(auth)
        {
            _channel = channelName;

            On["/" + channelName + "/nowplaying"] = _ =>
            {
                if (string.IsNullOrEmpty(_.Message) || _.Message == "remove")
                {
                    if (_waveOut != null)
                    {
                        _waveOut.Stop();
                    }
                    return;
                }

                Task.Run(() =>
                {
                    NowPlaying song = JsonConvert.DeserializeObject <NowPlaying>(_.Message);

                    if (!ASongHasPlayed)
                    {
                        // This is the first song to play in this channel (probably a partial)
                        ASongHasPlayed = true;
                    }
                    else if (ServerLag == null)
                    {
                        // This is the second song - capture the lag offset
                        ServerLag = Time.Timestamp() - song.votetime;
                        LogTo.Error("Server lag set to {0}ms", ServerLag.Value);
                    }
                    else
                    {
                        // This is the third song or later, adjust the time offset
                        song.votetime += ServerLag.Value;
                    }

                    song.votetime += PrefetchTime;

                    if (string.IsNullOrWhiteSpace(song.songID))
                    {
                        playingTrack = null;
                        LogTo.Warn("Server asked to play empty song on channel {0}", _channel);
                        return;
                    }

                    PlaySong(song.songID, UnixTimeBase.AddMilliseconds(song.votetime));
                });
            };

            Run();
        }
Example #23
0
        public async Task <NowPlaying> GetNowPlaying()
        {
            string nowPlayingJson = (await SafeEvaluateJavaScript("getNowPlaying();")).ToString();

            try
            {
                NowPlaying nowPlaying = JsonConvert.DeserializeObject <NowPlaying>(nowPlayingJson);
                return(nowPlaying);
            }
            catch
            {
                return(new NowPlaying());
            }
        }
        public async void OnTrackStartsPlaying(string title, string artist, string album, string trackNumber, int durationMs)
        {
            NowPlaying nowPlaying = CreateScrobble(title, artist, album, trackNumber, null, durationMs);

            Logger.Log(LogLevel.Info, $"Now playing: '{title}', artist: '{artist}', album: '{album}'");

            if (!string.IsNullOrWhiteSpace(ScrobblerConfig?.SessionKey))
            {
                await ShowBubbleOnErrorAsync(Track.UpdateNowPlaying(ScrobblerConfig.SessionKey, nowPlaying));
            }
            else
            {
                Logger.Log(LogLevel.Warn, $"Invalid session key. {NullSessionKeyErrorMessage}");
                ShowErrorBubble(NullSessionKeyErrorMessage);
            }
        }
Example #25
0
        public void PlayWavefile(Wavefile wavefile, TimeSpan delay)
        {
            if (wavefile == null)
            {
                return;
            }

            var playing = new NowPlaying
            {
                wavefile = wavefile,
                through  = -(int)(delay.TotalSeconds * SampleRate)
            };

            lock (m_lock)
            {
                nowPlaying = nowPlaying.AddHead(playing);
            }
        }
Example #26
0
 private void onBassEvent(object sender, BassEventArgs args)
 {
     if (args.Event == BassEvent.PlaybackFinished)
     {
         PlaybackState = PlaybackState.Stopped;
         var listItem = NowPlaying.Current();
         if (listItem.Key < NowPlaying.Count - 1)
         {
             Play(NowPlaying.Forward().Value);
         }
         else
         {
             if (Repeat)
             {
                 Play(NowPlaying.Forward().Value);
             }
         }
     }
 }
Example #27
0
        public IActionResult Get()
        {
            var lastFm = new NowPlaying(option.ApiKey);

            foreach (var user in option.Users)
            {
                var currentTrack = lastFm.GetTrackInfo(user);

                if (currentTrack != null)
                {
                    InvokeHub(_mapper.Map <TrackInfo, TrackInfoResource>(currentTrack));
                }
                return(Ok(currentTrack));
            }

            InvokeHub(_mapper.Map <TrackInfo, TrackInfoResource>(new TrackInfo()));

            return(Ok());
        }
Example #28
0
        public bool Enqueue(int identifier)
        {
            var item = LibraryActor.GetItem(identifier);

            if (item != null)
            {
                var added = NowPlaying.Enqueue(item);
                if (added.Value != null)
                {
                    if (PlaybackState == PlaybackState.Stopped)
                    {
                        var current = NowPlaying.Forward();
                        return(Play(current.Value));
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #29
0
        public bool Unregister(string userName, string clientName)
        {
            // Check for existence
            if (!this.Playing.Any(x => x.User.UserName == userName && x.User.CurrentSession.ClientName == clientName))
            {
                return(false);
            }

            // Grab instance
            NowPlaying nowPlaying = this.playing.Single(x => x.User.UserName == userName && x.User.CurrentSession.ClientName == clientName);

            // Disable timer
            nowPlaying.Timer.Stop();
            nowPlaying.Timer = null;

            // Remove from list
            this.playing.Remove(nowPlaying);

            return(true);
        }
Example #30
0
 public void OnQueryMessage(object sender, IrcEventArgs e)
 {
     Console.WriteLine($"[PM] {e.Data.Nick} : {e.Data.Message}");
     // Check NowPlaying
     if (NowPlayingParser.IsNowPlaying(e.Data.Message))
     {
         NowPlaying np = NowPlayingParser.Parse(e.Data.Message);
         new CommandResult()
         {
             Type   = CommandResultType.MESSAGE,
             Result = $"Is Mapset: {np.IsMapSet} | Id: {np.Id}\n" +
                      $"{np.Beatmap} {np.Url}"
         };
     }
     if (e.Data.Message.StartsWith('!'))
     {
         CommandParser parser = new CommandParser();
         parser.Parse(e.Data.Nick, e.Data.Message, true).Send(irc, e.Data.Nick);
     }
 }
Example #31
0
        public async Task <Player> SetPlayer(string stationId, string userId, NowPlaying np)
        {
            var player = await GetPlayer(stationId, userId);

            bool isNew = false;

            if (player == null)
            {
                isNew  = true;
                player = new Player(stationId, userId);
            }

            player.Artist     = np.Track?.Artists[0]?.Name;
            player.Track      = np.Track?.Name;
            player.DurationMs = np.Track?.DurationMs ?? 0;
            player.IsPlaying  = np.IsPlaying;

            if (np.Context == null)
            {
                player.Context = null;
            }
            else
            {
                player.Context = new Context {
                    Type = np.Context?.Type, Uri = np.Context?.Uri
                };
            }

            if (np.Offset == null)
            {
                player.EpochMs           = 0;
                player.PositionAtEpochMs = 0;
            }
            else
            {
                player.EpochMs           = Convert.ToInt64(np.Offset.Epoch.ToUnixTimeMilliseconds());
                player.PositionAtEpochMs = Convert.ToInt32(np.Offset.PositionAtEpoch.TotalMilliseconds);
            }

            return(isNew ? await _data.Create(player) : await _data.Replace(player, player.ETag));
        }