private void ButtonPrev1_Click(object sender, RoutedEventArgs e)
        {
            SelectedItem = SelectedItem.Previous;
            DefaultViewModel["Channel"] = SelectedItem;

            UpdatePlayStatus();
            UpdateChannelStatus();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Model = App.Main;
            SelectedItem = e.Parameter as ChannelItem;

            DefaultViewModel.Add("Model", Model);
            DefaultViewModel.Add("Channel", SelectedItem);

            UpdatePlayStatus();
            UpdateChannelStatus();
        }
예제 #3
0
        private static XmlDocument WideLiveTile(ChannelItem channel)
        {

            var tileTemplate = TileTemplateType.TileWide310x150SmallImageAndText04;
            var tileXml = TileUpdateManager.GetTemplateContent(tileTemplate);

            // Set notification image
            XmlNodeList imgNodes = tileXml.GetElementsByTagName("image");
            imgNodes[0].Attributes[1].NodeValue = channel.Image;

            // Set notification text
            XmlNodeList textNodes = tileXml.GetElementsByTagName("text");
            textNodes[0].InnerText = channel.Name;
            textNodes[1].InnerText = channel.Description;

            return tileXml;
        }
예제 #4
0
        public static void SetLiveTile(ChannelItem channel)
        {
            var update = TileUpdateManager.CreateTileUpdaterForApplication();

            if (channel == null)
            {
                update.Clear();
                return;
            }

            var smallXml = SmallLiveTile(channel);
            if (smallXml != null)
            {
                var smallTile = new TileNotification(smallXml);
                smallTile.ExpirationTime = DateTime.Now + TimeSpan.FromMinutes(30);
                update.Update(smallTile);
            }

            var wideXml = WideLiveTile(channel);
            if (wideXml != null)
            {
                var wideTile = new TileNotification(wideXml);
                wideTile.ExpirationTime = DateTime.Now + TimeSpan.FromMinutes(30);
                update.Update(wideTile);
            }
        }
예제 #5
0
        private void CreateEmptyChannels()
        {
            AllChannels = new ObservableCollection<ChannelItem>();

            int i = 0;

            foreach (var item in ChannelsHelper.ChannelsAssets)
            {
                var chn = new ChannelItem
                {
                    Key = item.Key,
                    Image = item.Value[0],
                    Color1 = item.Value[1],
                    Color2 = item.Value[2],
                    Streams = new List<string>()
                };

                if (i > 0)
                {
                    chn.Previous = AllChannels[AllChannels.Count - 1];
                    AllChannels[AllChannels.Count - 1].Next = chn;
                }

                AllChannels.Add(chn);
                i++;
            }

            // Get load the last 
            var channelKey = ApplicationData.Current.LocalSettings.Values["LastPlayedChannel"];
            if (channelKey != null)
            {
                foreach (var channel in AllChannels)
                {
                    if (channel.Key.Equals(channelKey))
                    {
                        NowPlayingItem = channel;
                        break;
                    }
                }
            }
        }
예제 #6
0
        public void PlayChannel(ChannelItem channel)
        {
            if (channel != null && channel.Streams.Count > 0)
            {
                StreamIndex = 0;
                NowPlayingItem = channel;
                MediaPlayer.Source = new Uri(channel.Streams[0]);

                SystemMediaTransportControlsDisplayUpdater updater = systemMediaControls.DisplayUpdater;
                updater.Type = MediaPlaybackType.Music;
                updater.MusicProperties.AlbumArtist = channel.NowPlaying.Track;
                updater.MusicProperties.Title = channel.Name;
                updater.Thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(channel.Image));
                updater.Update();
                SetLiveTile(channel);
            }
        }
예제 #7
0
        private async void LoadTrackHistory(ChannelItem channel)
        {
            channel.IsRefreshing = true;

            var data = await ChannelsHelper.DownloadJson(string.Format(ChannelsHelper.TRACK_HISTORY_URL, channel.ID));
            if (data == null)
            {
                channel.IsRefreshing = false;
                return;
            }

            TrackItem nowPl = null;
            var tempTracks = new List<TrackItem>();

            var index = 0;
            var tracks = JsonConvert.DeserializeObject(data) as JContainer;

            foreach (var track in tracks)
            {
                if ((string)track["type"] == "track")
                {
                    var item = new TrackItem
                    {
                        Index = index,
                        Track = (string)track["track"],
                        Started = (long)track["started"],
                        Duration = (int)track["length"]
                    };

                    if (nowPl == null) nowPl = item;
                    else tempTracks.Add(item);

                    if (index == 5) break;
                    index++;
                }
            }

            channel.TrackHistory = new ObservableCollection<TrackItem>(tempTracks);

            if (channel.NowPlaying != null && nowPl != null && channel.NowPlaying.Started == nowPl.Started)
            {
                // Extend with 1 minute if now playing is the same
                channel.NowPlaying.Duration += channel.NowPlaying.StartedTime + 10;
            }
            else
            {
                channel.NowPlaying = nowPl;
            }

            channel.IsRefreshing = false;
        }
 private void ButtonNext_Click(object sender, RoutedEventArgs e)
 {
     SelectedItem = SelectedItem.Next;
     IsRightDirection = true;
     FadeOutLeftStory.Begin();
 }
 private void ButtonPrev_Click(object sender, RoutedEventArgs e)
 {
     SelectedItem = SelectedItem.Previous;
     IsRightDirection = false;
     FadeOutRightStory.Begin();
 }