Example #1
0
        private async void GetNewTrack()
        {
            Task <Track> task   = RadioAPI.GetNowPlayingTrack();
            Track        result = await task;

            if (result == null)
            {
                ShowError();
            }
            else
            {
                Track newTrack = (Track)result;
                if (newTrack.trackName.Equals(currentTrack.trackName))
                {
                    return;
                }

                currentTrack     = (Track)result;
                trackName.Text   = currentTrack.trackName;
                artistName.Text  = currentTrack.artistName;
                trackName1.Text  = currentTrack.trackName;
                artistName1.Text = currentTrack.artistName;
                trackName2.Text  = currentTrack.trackName;
                artistName2.Text = currentTrack.artistName;

                trackTimeTicks = (RadioAPI.ConvertToUnixTimestamp(DateTime.UtcNow) - PlayerSettings.timeOffset) - currentTrack.startTime;
            }
        }
Example #2
0
        public async void LoadChannels()
        {
            HideChannelsError();
            HideChannelsGrid();
            ShowChannelsInfo();
            if (channels.Count > 0)
            {
                channels.Clear();
            }
            if (channelsPanel.Children.Count > 0)
            {
                channelsPanel.Children.Clear();
            }

            Task <List <Channel> > task   = RadioAPI.GetAllChannels();
            List <Channel>         result = await task;

            if (result == null)
            {
                HideChannelsInfo();
                ShowChannelsError();
            }
            else
            {
                channels = result;

                foreach (Channel channel in channels)
                {
                    channel.imageUrl = channel.imageUrl + "?width=" + 300;
                    AddChannels(channel);
                }
                HideChannelsInfo();
                ShowChannelsGrid();
            }
        }
Example #3
0
        private async void Play()
        {
            isPlay = true;
            HideError();

            Task <string> task1   = RadioAPI.Ping();
            string        result1 = await task1;

            Task <int> task   = RadioAPI.GetAudioLinks();
            int        result = await task;

            if (result == 1)
            {
                ShowError();
            }
            else
            {
                try
                {
                    player.Source     = MediaSource.CreateFromUri(new Uri(PlayerSettings.audioStream));
                    channelName.Text  = currentChannel.name;
                    channelName1.Text = currentChannel.name;
                    channelName2.Text = currentChannel.name;

                    contentPanel.Visibility = Visibility.Visible;

                    GetNewTrack();
                    //playButton.IsChecked = true;
                    //playButton1.IsChecked = true;
                    //playButton2.IsChecked = true;
                    trackTimeTimer.Start();
                    player.Play();
                }
                catch (ArgumentNullException)
                {
                    ShowError();
                }
                catch (UriFormatException)
                {
                    ShowError();
                }
            }
        }