Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            NotificationUtils.Initialize();

            var pl       = PlaylistsHelper.FromPath(@"https://smarttvnews.ru/apps/iptvchannels.m3u", (p) => NotificationUtils.ShowNotification(p, NotificationUtils.InfoType.Loading), CancellationToken.None);
            var channels = (pl as Playlist).Expand();

            vlc.Initialize(channels);
            vlc.Start();
            KeyDown += MainWindow_KeyDown;
        }
Exemplo n.º 2
0
        private void NewPlaylist(string path)
        {
            _cancellationTS_LoadPlaylist?.Cancel();
            _cancellationTS_LoadPlaylist = new CancellationTokenSource();
            _cancellationTS_LoadPlaylist.Token.Register(() =>
                                                        NotificationUtils.ShowNotification("Загрузка плейлиста отменена...", NotificationUtils.InfoType.VlcLoading));

            NotificationUtils.ShowNotification("Загрузка нового плейлиста...", NotificationUtils.InfoType.VlcLoading);

            Task.Factory.StartNew(() =>
            {
                MediaPath[] newPlaylist = null;
                var data = PlaylistsHelper.FromPath(
                    path,
                    (p) => NotificationUtils.ShowNotification(p + " загрузка...", NotificationUtils.InfoType.VlcLoading),
                    _cancellationTS_LoadPlaylist.Token,
                    isPlaylist: true);
                if (data is Playlist pl)
                {
                    newPlaylist = pl.Expand();
                }
                else if (data != null)
                {
                    newPlaylist = new[] { data }
                }
                ;
                if (newPlaylist != null && !_cancellationTS_LoadPlaylist.IsCancellationRequested)
                {
                    LoadPlaylist(newPlaylist);
                    InitCommands();
                    DataManager.Save(PlaylistPath, newPlaylist);
                    DataManager.Save(PlaylistUriPath, path);
                    _currentPlaylist = path;
                    NotificationUtils.ShowNotification("Плейлист загружен", NotificationUtils.InfoType.ChannelOK);
                }
                else
                {
                    NotificationUtils.ShowNotification("Плейлист не загружен", NotificationUtils.InfoType.Error);
                }
                _cancellationTS_LoadPlaylist = null;
            });
        }