protected void LoadPlayList(string strPlayList)
        {
            IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);

            if (loader == null)
            {
                return;
            }
            PlayList playlist = new PlayList();

            if (!loader.Load(playlist, strPlayList))
            {
                TellUserSomethingWentWrong();
                return;
            }

            playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
            if (playlist.Count == 1)
            {
                Log.Info("GUIVideoFiles: play single playlist item - {0}", playlist[0].FileName);
                if (g_Player.Play(playlist[0].FileName))
                {
                    if (Util.Utils.IsVideo(playlist[0].FileName))
                    {
                        g_Player.ShowFullScreenWindow();
                    }
                }
                return;
            }

            // clear current playlist
            playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Clear();

            // add each item of the playlist to the playlistplayer
            for (int i = 0; i < playlist.Count; ++i)
            {
                PlayListItem playListItem = playlist[i];
                playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playListItem);
            }

            // if we got a playlist
            if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Count > 0)
            {
                // then get 1st song
                playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO);
                PlayListItem item = playlist[0];

                // and start playing it
                playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO;
                playlistPlayer.Reset();
                playlistPlayer.Play(0);

                // and activate the playlist window if its not activated yet
                if (GetID == GUIWindowManager.ActiveWindow)
                {
                    GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
                }
            }
        }
Example #2
0
 public IEnumerable <WebPlaylist> GetPlaylists()
 {
     return(Directory.GetFiles(configuration["playlist"])
            .Where(p => PlayListFactory.IsPlayList(p))
            .Select(p => GetPlaylist(p))
            .Where(p => p != null)
            .ToList());
 }
Example #3
0
        public bool SavePlaylist(string playlistId, IEnumerable <WebPlaylistItem> playlistItems)
        {
            String      path       = GetPlaylistPath(playlistId);
            PlayList    mpPlaylist = new PlayList();
            IPlayListIO factory    = PlayListFactory.CreateIO(path);

            foreach (WebPlaylistItem i in playlistItems)
            {
                PlayListItem mpItem = new PlayListItem(i.Title, i.Path[0], i.Duration);
                mpItem.Type = PlayListItem.PlayListItemType.Audio;
                mpPlaylist.Add(mpItem);
            }

            return(factory.Save(mpPlaylist, path));
        }
 protected virtual void AddItemToPlayList(GUIListItem pItem)
 {
     if (!pItem.IsFolder)
     {
         //TODO
         if (Util.Utils.IsVideo(pItem.Path) && !PlayListFactory.IsPlayList(pItem.Path))
         {
             PlayListItem playlistItem = new PlayListItem();
             playlistItem.Type        = PlayListItem.PlayListItemType.Video;
             playlistItem.FileName    = pItem.Path;
             playlistItem.Description = pItem.Label;
             playlistItem.Duration    = pItem.Duration;
             playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playlistItem);
         }
     }
 }
        private void btnPlaylist_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.AddExtension    = false;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.Filter          = "playlists (*.m3u;*.pls;*.b4s;*.wpl)|*.m3u;*.pls;*.b4s;*.wpl";
            dlg.Multiselect     = false;
            dlg.Title           = "Select the playlist file to import";
            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            IPlayListIO listIO   = PlayListFactory.CreateIO(dlg.FileName);
            PlayList    playlist = new PlayList();

            if (!listIO.Load(playlist, dlg.FileName))
            {
                MessageBox.Show("There was an error parsing the playlist file", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            TvBusinessLayer layer     = new TvBusinessLayer();
            int             iInserted = 0;

            foreach (PlayListItem item in playlist)
            {
                if (string.IsNullOrEmpty(item.FileName))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(item.Description))
                {
                    item.Description = item.FileName;
                }
                Channel channel = new Channel(true, false, 0, Schedule.MinSchedule, false,
                                              Schedule.MinSchedule, 10000, true, "", item.Description, 10000);
                channel.Persist();
                layer.AddWebStreamTuningDetails(channel, item.FileName, 0);
                layer.AddChannelToRadioGroup(channel, TvConstants.RadioGroupNames.AllChannels);
                iInserted++;
            }
            MessageBox.Show("Imported " + iInserted + " new channels from playlist");
            OnSectionActivated();
        }
Example #6
0
        public IEnumerable <WebPlaylistItem> GetPlaylistItems(string playlistId)
        {
            PlayList    mpPlaylist = new PlayList();
            string      path       = GetPlaylistPath(playlistId);
            IPlayListIO factory    = PlayListFactory.CreateIO(path);

            if (factory.Load(mpPlaylist, path))
            {
                List <WebPlaylistItem> retList = new List <WebPlaylistItem>();
                foreach (PlayListItem i in mpPlaylist)
                {
                    WebPlaylistItem    webItem = new WebPlaylistItem();
                    WebMusicTrackBasic track   = LoadAllTracks <WebMusicTrackBasic>().FirstOrDefault(x => x.Path.Contains(i.FileName));

                    webItem.Title    = i.Description;
                    webItem.Duration = i.Duration;
                    webItem.Path     = new List <String>();
                    webItem.Path.Add(i.FileName);

                    if (track != null)
                    {
                        webItem.Id        = track.Id;
                        webItem.Type      = track.Type;
                        webItem.DateAdded = track.DateAdded;
                    }
                    else
                    {
                        Log.Warn("Couldn't get track information for " + i.FileName);
                    }

                    retList.Add(webItem);
                }
                return(retList);
            }
            else if (new FileInfo(path).Length == 0)
            {
                // for newly created playlists, return an empty list, to make sure that a CreatePlaylist call followed by an AddItem works
                return(new List <WebPlaylistItem>());
            }
            else
            {
                Log.Warn("Couldn't load playlist {0}", playlistId);
                return(null);
            }
        }
        protected override void OnClick(int iItem)
        {
            GUIListItem item = facadeLayout.SelectedListItem;

            if (item == null)
            {
                return;
            }

            if (PlayListFactory.IsPlayList(item.Path))
            {
                LoadPlayList(item.Path);
                return;
            }

            if (item.IsFolder)
            {
                if (item.Label == "..")
                {
                    // we have clicked on the ".." entry
                    // so go up a level in view
                    handler.CurrentLevel--;
                }
                else
                {
                    // this is a level in the view above the bottom
                    ((MusicViewHandler)handler).Select(item.AlbumInfoTag as Song);
                }

                m_iItemSelected = -1;
                LoadDirectory("db_view");
            }
            else
            {
                // we have selected an item at the bottom level of the view
                // so play what is selected
                bool clearPlaylist = false;
                if (_selectOption == "play" || !g_Player.Playing || !g_Player.IsMusic)
                {
                    clearPlaylist = true;
                }
                AddSelectionToCurrentPlaylist(clearPlaylist, _addAllOnSelect);
            }
        }
Example #8
0
        public string CreatePlaylist(string playlistName)
        {
            try
            {
                string fileName = playlistName + ".m3u";
                string path     = Path.Combine(configuration["playlist"], fileName);

                PlayList    mpPlaylist = new PlayList();
                IPlayListIO factory    = PlayListFactory.CreateIO(path);
                factory.Save(mpPlaylist, path);

                return(EncodeTo64(fileName));
            }
            catch (Exception ex)
            {
                Log.Error("Unable to create playlist " + playlistName, ex);
            }

            return(null);
        }
Example #9
0
        public IEnumerable <WebPlaylistItem> GetPlaylistItems(string playlistId)
        {
            PlayList    mpPlaylist = new PlayList();
            string      path       = GetPlaylistPath(playlistId);
            IPlayListIO factory    = PlayListFactory.CreateIO(path);

            if (factory.Load(mpPlaylist, path))
            {
                var tracks = LoadAllTracks <WebMusicTrackBasic>().ToList();

                return(mpPlaylist
                       .Select(x =>
                {
                    var track = tracks.FirstOrDefault(t => t.Path.Contains(x.FileName));
                    return new WebPlaylistItem()
                    {
                        Title = x.Description,
                        Duration = x.Duration,
                        Path = new List <string>()
                        {
                            x.FileName
                        },
                        Type = WebMediaType.MusicTrack,
                        Id = track != null ? track.Id : null,
                        DateAdded = track != null ? track.DateAdded : new DateTime(1970, 1, 1),
                        Artwork = track != null ? track.Artwork : new List <WebArtwork>(),
                    };
                })
                       .ToList());
            }
            else if (new FileInfo(path).Length == 0)
            {
                // for newly created playlists, return an empty list, to make sure that a CreatePlaylist call followed by an AddItem works
                return(new List <WebPlaylistItem>());
            }
            else
            {
                Log.Warn("Couldn't load playlist {0}", playlistId);
                return(null);
            }
        }
Example #10
0
        public void DoWork()
        {
            var layer = new TvBusinessLayer();

            _defaultTVGroup = layer.GetSetting("DVBIPScanUtilPluginSetupDefaultGroup", "New").Value;

            String EPGUtilPluginTuningXML = layer.GetSetting("DVBIPScanUtilPluginSetupTuningXML", "").Value;

            if (EPGUtilPluginTuningXML == "")
            {
                Log.Error("DVBIPScanUtilPlugin: missing tuning config");
                return;
            }

            IPlayListIO playlistIO =
                PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, EPGUtilPluginTuningXML));

            playlistIO.Load(playlist,
                            String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, EPGUtilPluginTuningXML));

            if (playlist.Count == 0)
            {
                return;
            }

            IList <Card> dbsCards = Card.ListAll();

            foreach (Card card in dbsCards)
            {
                if (CardType.DvbIP == RemoteControl.Instance.Type(card.IdCard))
                {
                    Log.Debug("DoScan card: " + card.IdCard);

                    _cardNumber = card.IdCard;

                    DoScan();
                }
            }
        }
Example #11
0
        private WebPlaylist GetPlaylist(string path)
        {
            PlayList    mpPlaylist = new PlayList();
            IPlayListIO factory    = PlayListFactory.CreateIO(path);

            if (factory.Load(mpPlaylist, path))
            {
                WebPlaylist webPlaylist = new WebPlaylist()
                {
                    Id = EncodeTo64(Path.GetFileName(path)), Title = mpPlaylist.Name, Path = new List <string>()
                    {
                        path
                    }
                };
                webPlaylist.ItemCount = mpPlaylist.Count;
                return(webPlaylist);
            }
            else
            {
                Log.Warn("Couldn't parse playlist " + path);
                return(null);
            }
        }
        private void LoadFacade()
        {
            TimeSpan totalPlayingTime = new TimeSpan();
            PlayList pl   = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
            Song     song = new Song();

            if (facadeLayout != null)
            {
                facadeLayout.Clear();
            }

            for (int i = 0; i < pl.Count; i++)
            {
                PlayListItem pi = pl[i];
                if (PlayListFactory.IsPlayList(pi.FileName))
                {
                    pl.Remove(pi.FileName, false);
                    LoadPlayList(pi.FileName, false, false, false, false);
                }
                // refresh pi if .m3u are cleaned up
                pi = pl[i];
                GUIListItem pItem = new GUIListItem(pi.Description);
                MusicTag    tag   = new MusicTag();
                if (m_database.GetSongByFileName(pi.FileName, ref song))
                {
                    tag         = song.ToMusicTag();
                    pi.MusicTag = tag;
                }
                else
                {
                    tag         = TagReader.TagReader.ReadTag(pi.FileName);
                    pi.MusicTag = tag;
                }
                bool dirtyTag = false;
                if (tag != null)
                {
                    pItem.MusicTag = tag;
                    if (tag.Title == ("unknown") || tag.Title.IndexOf("unknown") > 0 || tag.Title == string.Empty)
                    {
                        dirtyTag = true;
                    }
                }
                else
                {
                    dirtyTag = true;
                }

                if (tag != null && !dirtyTag)
                {
                    int    playCount = tag.TimesPlayed;
                    string duration  = Util.Utils.SecondsToHMSString(tag.Duration);
                    pItem.Label    = string.Format("{0} - {1}", tag.Artist, tag.Title);
                    pItem.Label2   = duration;
                    pItem.MusicTag = pi.MusicTag;
                }

                pItem.Path     = pi.FileName;
                pItem.IsFolder = false;

                if (pi.Duration > 0)
                {
                    totalPlayingTime = totalPlayingTime.Add(new TimeSpan(0, 0, pi.Duration));
                }

                if (pi.Played)
                {
                    pItem.Shaded = true;
                }

                Util.Utils.SetDefaultIcons(pItem);

                pItem.OnRetrieveArt  += new GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
                pItem.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);

                facadeLayout.Add(pItem);
            }

            int iTotalItems = facadeLayout.Count;

            if (iTotalItems > 0)
            {
                GUIListItem rootItem = facadeLayout[0];
                if (rootItem.Label == "..")
                {
                    iTotalItems--;
                }
            }

            //set object count label, total duration
            GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(iTotalItems));

            if (totalPlayingTime.TotalSeconds > 0)
            {
                GUIPropertyManager.SetProperty("#totalduration",
                                               Util.Utils.SecondsToHMSString((int)totalPlayingTime.TotalSeconds));
            }
            else
            {
                GUIPropertyManager.SetProperty("#totalduration", string.Empty);
            }

            SelectCurrentItem();
            UpdateButtonStates();
        }
Example #13
0
        private void DoScan()
        {
            int tvChannelsNew        = 0;
            int radioChannelsNew     = 0;
            int tvChannelsUpdated    = 0;
            int radioChannelsUpdated = 0;

            string buttonText = mpButtonScanTv.Text;
            IUser  user       = new User();

            user.CardId = _cardNumber;
            try
            {
                // First lock the card, because so that other parts of a hybrid card can't be used at the same time
                _isScanning         = true;
                _stopScanning       = false;
                mpButtonScanTv.Text = "Cancel...";
                RemoteControl.Instance.EpgGrabberEnabled = false;
                listViewStatus.Items.Clear();

                PlayList playlist = new PlayList();
                if (mpComboBoxService.SelectedIndex == 0)
                {
                    //TODO read SAP announcements
                }
                else
                {
                    IPlayListIO playlistIO =
                        PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath,
                                                               mpComboBoxService.SelectedItem));
                    playlistIO.Load(playlist,
                                    String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath,
                                                  mpComboBoxService.SelectedItem));
                }
                if (playlist.Count == 0)
                {
                    return;
                }

                mpComboBoxService.Enabled    = false;
                checkBoxCreateGroups.Enabled = false;
                checkBoxEnableChannelMoveDetection.Enabled = false;
                TvBusinessLayer layer = new TvBusinessLayer();
                Card            card  = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber));

                int index = -1;
                IEnumerator <PlayListItem> enumerator = playlist.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    if (_stopScanning)
                    {
                        return;
                    }
                    index++;
                    float percent = ((float)(index)) / playlist.Count;
                    percent *= 100f;
                    if (percent > 100f)
                    {
                        percent = 100f;
                    }
                    progressBar1.Value = (int)percent;

                    string url  = enumerator.Current.FileName.Substring(enumerator.Current.FileName.LastIndexOf('\\') + 1);
                    string name = enumerator.Current.Description;

                    DVBIPChannel tuneChannel = new DVBIPChannel();
                    tuneChannel.Url  = url;
                    tuneChannel.Name = name;
                    string       line = String.Format("{0}- {1} - {2}", 1 + index, tuneChannel.Name, tuneChannel.Url);
                    ListViewItem item = listViewStatus.Items.Add(new ListViewItem(line));
                    item.EnsureVisible();
                    RemoteControl.Instance.Tune(ref user, tuneChannel, -1);
                    IChannel[] channels;
                    channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel);
                    UpdateStatus();
                    if (channels == null || channels.Length == 0)
                    {
                        if (RemoteControl.Instance.TunerLocked(_cardNumber) == false)
                        {
                            line           = String.Format("{0}- {1} :No Signal", 1 + index, tuneChannel.Url);
                            item.Text      = line;
                            item.ForeColor = Color.Red;
                            continue;
                        }
                        else
                        {
                            line           = String.Format("{0}- {1} :Nothing found", 1 + index, tuneChannel.Url);
                            item.Text      = line;
                            item.ForeColor = Color.Red;
                            continue;
                        }
                    }

                    int newChannels     = 0;
                    int updatedChannels = 0;

                    for (int i = 0; i < channels.Length; ++i)
                    {
                        Channel      dbChannel;
                        DVBIPChannel channel = (DVBIPChannel)channels[i];
                        if (channels.Length > 1)
                        {
                            if (channel.Name.IndexOf("Unknown") == 0)
                            {
                                channel.Name = name + (i + 1);
                            }
                        }
                        else
                        {
                            channel.Name = name;
                        }
                        bool         exists;
                        TuningDetail currentDetail;
                        //Check if we already have this tuningdetail. According to DVB-IP specifications there are two ways to identify DVB-IP
                        //services: one ONID + SID based, the other domain/URL based. At this time we don't fully and properly implement the DVB-IP
                        //specifications, so the safest method for service identification is the URL. The user has the option to enable the use of
                        //ONID + SID identification and channel move detection...
                        if (checkBoxEnableChannelMoveDetection.Checked)
                        {
                            currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.ServiceId,
                                                                  TvBusinessLayer.GetChannelType(channel));
                        }
                        else
                        {
                            currentDetail = layer.GetTuningDetail(channel.Url, TvBusinessLayer.GetChannelType(channel));
                        }

                        if (currentDetail == null)
                        {
                            //add new channel
                            exists              = false;
                            dbChannel           = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber);
                            dbChannel.SortOrder = 10000;
                            if (channel.LogicalChannelNumber >= 1)
                            {
                                dbChannel.SortOrder = channel.LogicalChannelNumber;
                            }
                            dbChannel.IsTv    = channel.IsTv;
                            dbChannel.IsRadio = channel.IsRadio;
                            dbChannel.Persist();
                        }
                        else
                        {
                            exists    = true;
                            dbChannel = currentDetail.ReferencedChannel();
                        }

                        layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);

                        if (checkBoxCreateGroups.Checked)
                        {
                            layer.AddChannelToGroup(dbChannel, channel.Provider);
                        }
                        if (currentDetail == null)
                        {
                            layer.AddTuningDetails(dbChannel, channel);
                        }
                        else
                        {
                            //update tuning details...
                            TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
                            td.Persist();
                        }

                        if (channel.IsTv)
                        {
                            if (exists)
                            {
                                tvChannelsUpdated++;
                                updatedChannels++;
                            }
                            else
                            {
                                tvChannelsNew++;
                                newChannels++;
                            }
                        }
                        if (channel.IsRadio)
                        {
                            if (exists)
                            {
                                radioChannelsUpdated++;
                                updatedChannels++;
                            }
                            else
                            {
                                radioChannelsNew++;
                                newChannels++;
                            }
                        }
                        layer.MapChannelToCard(card, dbChannel, false);
                        line = String.Format("{0}- {1} :New:{2} Updated:{3}", 1 + index, tuneChannel.Name, newChannels,
                                             updatedChannels);
                        item.Text = line;
                    }
                }
                //DatabaseManager.Instance.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            finally
            {
                RemoteControl.Instance.StopCard(user);
                RemoteControl.Instance.EpgGrabberEnabled = true;
                progressBar1.Value           = 100;
                mpComboBoxService.Enabled    = true;
                checkBoxCreateGroups.Enabled = true;
                checkBoxEnableChannelMoveDetection.Enabled = true;
                mpButtonScanTv.Text = buttonText;
                _isScanning         = false;
            }
            ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done..."));

            lastItem =
                listViewStatus.Items.Add(
                    new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", radioChannelsNew,
                                                   radioChannelsUpdated)));
            lastItem =
                listViewStatus.Items.Add(
                    new ListViewItem(String.Format("Total tv channels new:{0} updated:{1}", tvChannelsNew, tvChannelsUpdated)));
            lastItem.EnsureVisible();
        }
Example #14
0
        /// <summary>
        /// Loads a new Directory
        /// </summary>
        /// <param name="newFolderName">Name of the folder</param>
        private void LoadDirectory(string newFolderName)
        {
            _disableSorting = false;
            String currentFolder = newFolderName;

            GUIControl.ClearControl(GetID, facadeView.GetID);
            List <GUIListItem> itemlist     = _mDirectory.GetDirectoryExt(currentFolder);
            List <GUIListItem> itemfiltered = new List <GUIListItem>();

            for (int x = 0; x < itemlist.Count; ++x)
            {
                bool        addItem = true;
                GUIListItem item1   = itemlist[x];
                for (int y = 0; y < itemlist.Count; ++y)
                {
                    GUIListItem item2 = itemlist[y];
                    if (x != y)
                    {
                        if (!item1.IsFolder || !item2.IsFolder)
                        {
                            if (!item1.IsRemote && !item2.IsRemote)
                            {
                                if (Utils.ShouldStack(item1.Path, item2.Path))
                                {
                                    if (String.Compare(item1.Path, item2.Path, true) > 0)
                                    {
                                        addItem = false;
                                        // Update to reflect the stacked size
                                        item1.FileInfo.Length += item2.FileInfo.Length;
                                    }
                                }
                            }
                        }
                    }
                }

                if (addItem)
                {
                    string label = item1.Label;

                    Utils.RemoveStackEndings(ref label);
                    item1.Label = label;
                    if (_treatPlaylistsAsFolders && PlayListFactory.IsPlayList(item1.Path))
                    {
                        item1.IsFolder = true;
                        Utils.SetDefaultIcons(item1);
                    }
                    itemfiltered.Add(item1);
                }
            }
            itemlist = itemfiltered;

            if (_treatPlaylistsAsFolders && PlayListFactory.IsPlayList(newFolderName))
            {
                IPlayListIO loader   = PlayListFactory.CreateIO(newFolderName);
                PlayList    playlist = new PlayList();
                _disableSorting = true;
                String basePath = Path.GetDirectoryName(Path.GetFullPath(newFolderName));
                if (loader.Load(playlist, newFolderName))
                {
                    foreach (PlayListItem plItem in playlist)
                    {
                        GUIListItem item = new GUIListItem {
                            Path = plItem.FileName
                        };
                        if (plItem.FileName.StartsWith(basePath))
                        {
                            String mainPath = plItem.FileName.Remove(0, basePath.Length + 1);
                            if (mainPath.StartsWith("cue://") ||
                                mainPath.StartsWith("cue://") ||
                                mainPath.StartsWith("http://") ||
                                mainPath.StartsWith("ftp://") ||
                                mainPath.StartsWith("http_proxy://") ||
                                mainPath.StartsWith("mms://") ||
                                mainPath.StartsWith("mmst://") ||
                                mainPath.StartsWith("mpst://") ||
                                mainPath.StartsWith("rtsp://") ||
                                mainPath.StartsWith("rtp://") ||
                                mainPath.StartsWith("sdp://") ||
                                mainPath.StartsWith("udp://") ||
                                mainPath.StartsWith("unsv://"))
                            {
                                item.Path = mainPath;
                            }
                        }
                        Log.Info("MPlayer GUI: " + item.Path);

                        item.Label    = plItem.Description;
                        item.IsFolder = false;
                        Utils.SetDefaultIcons(item);
                        itemlist.Add(item);
                    }
                }
            }

            foreach (GUIListItem item in itemlist)
            {
                facadeView.Add(item);
            }
            OnSort();
        }
Example #15
0
        /// <summary>
        /// Loads a playlist and starts the playback
        /// </summary>
        /// <param name="playListFileName">Filename of the playlist</param>
        private void LoadPlayList(string playListFileName)
        {
            IPlayListIO loader   = PlayListFactory.CreateIO(playListFileName);
            PlayList    playlist = new PlayList();

            if (!loader.Load(playlist, playListFileName))
            {
                GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                if (dlgOk != null)
                {
                    dlgOk.SetHeading(6);
                    dlgOk.SetLine(1, 477);
                    dlgOk.SetLine(2, String.Empty);
                    dlgOk.DoModal(GetID);
                }
                return;
            }
            if (playlist.Count == 1)
            {
                string movieFileName = playlist[0].FileName + ".mplayer";
                if (movieFileName.StartsWith("rtsp:"))
                {
                    movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5);
                }
                if (g_Player.Play(movieFileName))
                {
                    if (g_Player.Player != null && g_Player.IsVideo)
                    {
                        GUIGraphicsContext.IsFullScreenVideo = true;
                        GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO);
                    }
                }
                return;
            }

            PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Clear();

            for (int i = 0; i < playlist.Count; ++i)
            {
                string movieFileName = playlist[i].FileName + ".mplayer";
                if (movieFileName.StartsWith("rtsp:"))
                {
                    movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5);
                }
                playlist[i].FileName = movieFileName;
                PlayListItem playListItem = playlist[i];
                playListItem.Type = PlayListItem.PlayListItemType.Unknown;
                PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playListItem);
            }


            if (PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Count > 0)
            {
                PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO);
                PlaylistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO;
                PlaylistPlayer.Reset();
                PlaylistPlayer.Play(0);

                if (g_Player.Player != null && g_Player.IsVideo)
                {
                    GUIGraphicsContext.IsFullScreenVideo = true;
                    GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Handles the click in the facadeview
        /// </summary>
        private void OnClick()
        {
            GUIListItem item = facadeView.SelectedListItem;

            if (item == null)
            {
                return;
            }
            bool   isFolderAMovie = false;
            string path           = item.Path;

            if (item.IsFolder && !item.IsRemote)
            {
                // Check if folder is actually a DVD. If so don't browse this folder, but play the DVD!
                if ((File.Exists(path + @"\VIDEO_TS\VIDEO_TS.IFO")) && (item.Label != ".."))
                {
                    isFolderAMovie = true;
                    if (_useDvdnav)
                    {
                        path = "dvdnav://" + path;
                    }
                    else
                    {
                        path = "dvd://" + path;
                    }
                    //_path = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
                }
                else if ((File.Exists(path + @"\MPEGAV\AVSEQ01.DAT")) && (item.Label != ".."))
                {
                    isFolderAMovie = true;
                    path           = "vcd://" + String.Format(@"{0}\MPEGAV\AVSEQ01.DAT", item.Path);
                }
                else if ((File.Exists(path + @"\MPEG2\AVSEQ01.MPG")) && (item.Label != ".."))
                {
                    isFolderAMovie = true;
                    path           = "svcd://" + String.Format(@"{0}\MPEG2\AVSEQ01.MPG", item.Path);
                }
                else if ((File.Exists(path + @"\MPEG2\AVSEQ01.MPEG")) && (item.Label != ".."))
                {
                    isFolderAMovie = true;
                    path           = "svcd://" + String.Format(@"{0}\MPEG2\AVSEQ01.MPEG", item.Path);
                }
            }

            if ((item.IsFolder) && (!isFolderAMovie))
            {
                //currentSelectedItem = -1;
                _virtualPath = path;
                LoadDirectory(path);
            }
            else
            {
                if (PlayListFactory.IsPlayList(path))
                {
                    LoadPlayList(path);
                    return;
                }
                string movieFileName = _mDirectory.GetLocalFilename(path) + ".mplayer";
                if (movieFileName.StartsWith("rtsp:"))
                {
                    movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5);
                }
                g_Player.Play(movieFileName);
                if (g_Player.IsVideo)
                {
                    GUIGraphicsContext.IsFullScreenVideo = true;
                    GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO);
                }
                return;
            }
        }