Beispiel #1
0
        /// <summary>
        /// Play the track.
        /// </summary>
        /// <param name="track">The track to play.</param>
        public static Task Play(QueueTrack track)
        {
            string artists          = String.Empty;
            string url              = String.Empty;
            string embeddedVideoUrl = String.Empty;

            if (track.Artists != null)
            {
                artists = StringHelper.ArrayToString(track.Artists);
            }

            // If we have the Youtube ID we can construct the URL, otherwise
            // send a request to youtube API for the information.
            if (String.IsNullOrEmpty(track.YoutubeId))
            {
                url = YoutubeApi.SingleResultSearch(track.Name + artists);
            }
            else
            {
                url = "https://www.youtube.com/watch?v=" + track.YoutubeId;
            }

            embeddedVideoUrl = LibVideo.GetLink(url);

            SendAudioToVoice(embeddedVideoUrl);

            return(Task.CompletedTask);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainWindow()
        {
            // Must be run before the brower control is initialised.
            InitialiseCefSharpBrowser();

            // Initialise WPF window component.
            InitializeComponent();

            InitialiseSpotifyApi();
            YoutubeApi.Authenticate();

            viewModel = (ApplicationViewModel)this.DataContext;

            // Add the side menu buttons to the buttons list for later use.
            buttons.Add(YouTubeButton);
            buttons.Add(SpotifyButton);
            buttons.Add(QueueButton);

            this.Closed += MainWindow_Closed;

            // Set Youtube and Queue grid visibility to collapsed so
            // controls from those grids are not visible on statup.
            YoutubeGrid.Visibility = Visibility.Collapsed;
            QueueGrid.Visibility   = Visibility.Collapsed;

            sliderTimer.Interval = TimeSpan.FromSeconds(1);
            sliderTimer.Tick    += SliderTimer_Tick;
            sliderTimer.Start();
        }