Ejemplo n.º 1
0
        private void DeleteVideoDirectory(string strPath)
        {
            string     dvdFolder = string.Empty;
            string     bdFolder  = string.Empty;
            GUIMessage msg       = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEODIRECTORY_DELETED, 0, 0, 0, 0, 0,
                                                  null);

            msg.Label = strPath;
            GUIWindowManager.SendMessage(msg);
            try
            {
                // Check if DVD/BD main folder is removed (strange case but can happen) and parent folder
                // still exist
                if (strPath.ToUpperInvariant().Contains(@"\VIDEO_TS"))
                {
                    dvdFolder = strPath.Substring(0, strPath.ToUpperInvariant().IndexOf(@"\VIDEO_TS"));
                    //VideoDatabase.DeleteMoviesInFolder(dvdFolder);
                }
                else if (strPath.ToUpperInvariant().Contains(@"\BDMV"))
                {
                    bdFolder = strPath.Substring(0, strPath.ToUpperInvariant().IndexOf(@"\BDMV"));
                    //VideoDatabase.DeleteMoviesInFolder(bdFolder);
                }
                else
                {
                    // Update video database
                    //VideoDatabase.DeleteMoviesInFolder(strPath);
                }
            }
            catch (Exception ex)
            {
                Log.Error("VideoFolderWatcher: VideoDatabase update for directory {0}, error: {1}", strPath, ex.Message);
                return;
            }
        }
Ejemplo n.º 2
0
        public static bool RequestPin()
        {
            bool retry  = true;
            bool sucess = false;

            while (retry)
            {
                var msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);
                GUIWindowManager.SendMessage(msgGetPassword);

                if (msgGetPassword.Label == _pin)
                {
                    sucess = true;
                }

                if (sucess)
                {
                    return(true);
                }

                var msgWrongPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD, 0, 0, 0, 0, 0,
                                                      0);
                GUIWindowManager.SendMessage(msgWrongPassword);

                if (!(bool)msgWrongPassword.Object)
                {
                    retry = false;
                }
            }
            return(false);
        }
        internal static void SendMovieRefresh()
        {
            // Send global message that movie is refreshed/scanned
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);

            GUIWindowManager.SendMessage(msg);
        }
        private void DeletePictures(string strFilename)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PICTURESFILE_DELETED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label = strFilename;
            GUIWindowManager.SendMessage(msg);
        }
        private void AddMusicDirectory(string strPath)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MUSICDIRECTORY_CREATED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label = strPath;
            GUIWindowManager.SendMessage(msg);
        }
        private void DeleteMusic(string strFilename)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MUSICFILE_DELETED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label = strFilename;
            GUIWindowManager.SendMessage(msg);
        }
        private void AddPicturesDirectory(string strPath)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PICTURESDIRECTORY_CREATED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label = strPath;
            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 8
0
        private void SetPin()
        {
            var msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);

            GUIWindowManager.SendMessage(msgGetPassword);

            _pin = msgGetPassword.Label;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// set the oversan of MediaPortal by setting crop parameters
        /// </summary>
        private void SetCropMode()
        {
            GUIMessage msg = new GUIMessage();

            msg.Message = GUIMessage.MessageType.GUI_MSG_PLANESCENE_CROP;
            msg.Object  = cropSettings;
            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 10
0
 private void OnProgramTimerTickEvent(object sender, ElapsedEventArgs e)
 {
     if (g_Player.IsRadio)
     {
         GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PROGRAM_INFO, 0, 0, 0, 0, 0, null);
         GUIWindowManager.SendMessage(msg);
     }
 }
Ejemplo n.º 11
0
        private void AddVideo(string strFilename)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOFILE_CREATED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label = strFilename;
            GUIWindowManager.SendMessage(msg);
        }
        private void RenamePictures(string oldFilename, string newFilename)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PICTURESFILE_RENAMED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label  = newFilename;
            msg.Label2 = oldFilename;
            GUIWindowManager.SendMessage(msg);
        }
        private void RenamePicturesDirectory(string oldDirectory, string newDirectory)
        {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PICTURESDIRECTORY_RENAMED, 0, 0, 0, 0, 0,
                                            null);

            msg.Label  = newDirectory;
            msg.Label2 = oldDirectory;
            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 14
0
        // Protected content PIN validation (any PIN from video protected folders is valid)
        private bool RequestPin()
        {
            bool retry  = true;
            bool sucess = false;

            currentProtectedShare.Clear();
            while (retry)
            {
                GUIMessage msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);
                GUIWindowManager.SendMessage(msgGetPassword);
                int iPincode = -1;
                try
                {
                    iPincode = Int32.Parse(msgGetPassword.Label);
                }
                catch (Exception) {}

                foreach (string p in protectedShares)
                {
                    char[]   splitter = { '|' };
                    string[] pin      = p.Split(splitter);

                    if (iPincode != Convert.ToInt32(pin[0]))
                    {
                        currentPin = iPincode;
                        continue;
                    }
                    if (iPincode == Convert.ToInt32(pin[0]))
                    {
                        currentPin = iPincode;
                        currentProtectedShare.Add(pin[1]);
                        sucess = true;
                    }
                }

                if (sucess)
                {
                    return(true);
                }

                GUIMessage msgWrongPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD, 0, 0, 0, 0, 0,
                                                             0);
                GUIWindowManager.SendMessage(msgWrongPassword);

                if (!(bool)msgWrongPassword.Object)
                {
                    retry = false;
                }
                else
                {
                    retry = true;
                }
            }
            currentPin = 0;
            return(false);
        }
        private void DeletePicturesDirectory(string strPath)
        {
            string     dvdFolder = string.Empty;
            string     bdFolder  = string.Empty;
            GUIMessage msg       = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PICTURESDIRECTORY_DELETED, 0, 0, 0, 0, 0,
                                                  null);

            msg.Label = strPath;
            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 16
0
        public override void OnDeviceRestored()
        {
            base.OnDeviceRestored();

            if (GUIGraphicsContext.Fullscreen && g_Player.IsMusic && g_Player.Playing)
            {
                // Make sure we don't go into fullscreen exclusive mode!
                Log.Info("GUIMusicFullscreen Window: Disabling DX9 exclusive mode");
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null);
                GUIWindowManager.SendMessage(msg);
            }
        }
Ejemplo n.º 17
0
 public override void Stop()
 {
     if (_state != PlayState.Init)
     {
         Log.Info("RTSPPlayer:ended {0}", m_strCurrentFile);
         m_strCurrentFile = "";
         CloseInterfaces();
         _state = PlayState.Init;
         GUIGraphicsContext.IsPlaying = false;
         GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_STOP_SERVER_TIMESHIFTING, 0, 0, 0, 0, 0, null);
         GUIWindowManager.SendMessage(msg);
     }
 }
Ejemplo n.º 18
0
        private void UpdateNews(bool bShowWarning)
        {
            GUIDialogProgress dlgProgress =
                (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

            try
            {
                if (m_strSiteURL.ToLowerInvariant().StartsWith("http://") == false &&
                    m_strSiteURL.ToLowerInvariant().StartsWith("file://") == false)
                {
                    m_strSiteURL = "http://" + m_strSiteURL;
                }

                long startTime = Environment.TickCount;
                dlgProgress.SetHeading(704);
                dlgProgress.SetLine(1, GUILocalizeStrings.Get(705) + " " + m_strSiteName);
                dlgProgress.SetLine(2, "");
                dlgProgress.SetLine(3, "");
                dlgProgress.ShowProgressBar(false);
                dlgProgress.StartModal(GetID);
                dlgProgress.Progress();

                Uri newURL = new Uri(m_strSiteURL);
                Download(newURL);
                UpdateButtons();

                // Leave dialog on screen for minimum of 1 seconds
                // to eliminate the horrible flash of dialog before user can reed it
                long endTime = Environment.TickCount;
                if (endTime - startTime < 1000)
                {
                    Thread.Sleep((int)(1000 - (endTime - startTime)));
                }
                dlgProgress.Close();
            }
            catch (Exception e)
            {
                dlgProgress.Close();
                if (bShowWarning)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0);
                    msg.Param1 = 9;   //my news
                    msg.Param2 = 912; //Unable to download latest news
                    msg.Param3 = 0;
                    msg.Label3 = m_strSiteURL;
                    GUIWindowManager.SendMessage(msg);
                    Log.Error(e);
                }
            }
        }
Ejemplo n.º 19
0
        private bool SetPin()
        {
            var msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);

            GUIWindowManager.SendMessage(msgGetPassword);

            try
            {
                int iPincode = Int32.Parse(msgGetPassword.Label);
                _pin = iPincode.ToString(CultureInfo.InvariantCulture);
                return(true);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception) {}
            // ReSharper restore EmptyGeneralCatchClause
            return(false);
        }
Ejemplo n.º 20
0
        private bool SetPin()
        {
            int        iPincode       = -1;
            GUIMessage msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);

            GUIWindowManager.SendMessage(msgGetPassword);

            try
            {
                iPincode  = Int32.Parse(msgGetPassword.Label);
                _pin      = iPincode.ToString();
                _unlocked = false;
                return(true);
            }
            catch (Exception) {}
            return(false);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Uses the static cropping system to execute the cropping
        /// </summary>
        private void RequestCrop(CropSettings cropSettings)
        {
            if (verboseLog)
            {
                Log.Debug("AutoCropper: RequestCrop");
            }
            // Send message to planescene with crop
            GUIMessage msg = new GUIMessage();

            msg.Message = GUIMessage.MessageType.GUI_MSG_PLANESCENE_CROP;
            msg.Object  = cropSettings;
            GUIWindowManager.SendMessage(msg);
            lastSettings.Bottom = cropSettings.Bottom;
            lastSettings.Top    = cropSettings.Top;
            lastSettings.Left   = cropSettings.Left;
            lastSettings.Right  = cropSettings.Right;
        }
        protected override void ExclusiveMode(bool onOff)
        {
            GUIMessage msg = null;

            if (onOff)
            {
                Log.Info("TSReaderPlayer: Enabling DX9 exclusive mode");
                if (_isRadio == false)
                {
                    msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 1, 0, null);
                }
            }
            else
            {
                Log.Info("TSReaderPlayer: Disabling DX9 exclusive mode");
                msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null);
            }
            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 23
0
        protected override void OnPageLoad()
        {
            Log.Info("RadioHome:OnPageLoad");
            base.OnPageLoad();
            GUIMessage msgStopRecorder = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORDER_STOP, 0, 0, 0, 0, 0, null);

            GUIWindowManager.SendMessage(msgStopRecorder);
            switch (currentSortMethod)
            {
            case SortMethod.Name:
                btnSortBy.SelectedItem = 0;
                break;

            case SortMethod.Type:
                btnSortBy.SelectedItem = 1;
                break;

            case SortMethod.Genre:
                btnSortBy.SelectedItem = 2;
                break;

            case SortMethod.Bitrate:
                btnSortBy.SelectedItem = 3;
                break;

            case SortMethod.Number:
                btnSortBy.SelectedItem = 4;
                break;
            }

            SelectCurrentItem();
            LoadDirectory(currentFolder);

            SetLastChannel();

            if ((_autoTurnOnRadio) && !(g_Player.Playing && g_Player.IsRadio))
            {
                Play(facadeLayout.SelectedListItem);
            }

            btnSortBy.SortChanged += SortChanged;
        }
Ejemplo n.º 24
0
        public static bool RequestPin()
        {
            bool retry  = true;
            bool sucess = false;

            while (retry)
            {
                GUIMessage msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);
                GUIWindowManager.SendMessage(msgGetPassword);
                int iPincode = -1;
                try
                {
                    iPincode = Int32.Parse(msgGetPassword.Label);
                }
                catch (Exception) { }

                if (iPincode == Convert.ToInt32(_pin))
                {
                    sucess = true;
                }

                if (sucess)
                {
                    return(true);
                }

                GUIMessage msgWrongPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD, 0, 0, 0, 0, 0,
                                                             0);
                GUIWindowManager.SendMessage(msgWrongPassword);

                if (!(bool)msgWrongPassword.Object)
                {
                    retry = false;
                }
                else
                {
                    retry = true;
                }
            }
            return(false);
        }
Ejemplo n.º 25
0
        protected virtual void SwitchToNextAllowedLayout(GUIFacadeControl.Layout selectedLayout)
        {
            int iSelectedLayout = (int)selectedLayout;
            int totalLayouts    = Enum.GetValues(typeof(GUIFacadeControl.Layout)).Length - 1;

            if (iSelectedLayout > totalLayouts)
            {
                iSelectedLayout = 0;
            }

            bool shouldContinue = true;

            do
            {
                if (!AllowLayout(selectedLayout) || facadeLayout.IsNullLayout(selectedLayout))
                {
                    iSelectedLayout++;
                    if (iSelectedLayout > totalLayouts)
                    {
                        iSelectedLayout = 0;
                    }
                }
                else
                {
                    shouldContinue = false;
                }
            } while (shouldContinue);

            CurrentLayout = (GUIFacadeControl.Layout)iSelectedLayout;

            SwitchLayout();

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LAYOUT_CHANGED, 0, 0, 0, 0, 0, 0);

            GUIWindowManager.SendMessage(msg);
        }
Ejemplo n.º 26
0
        public static bool Mount(string IsoFile, out string VirtualDrive)
        {
            if (g_Player.Playing)
            {
                //string file = g_Player.CurrentFile;
                //if (g_Player.CheckIfImage(file))
                {
                    g_Player.Stop();
                }
            }
            VirtualDrive = string.Empty;
            if (IsoFile == null)
            {
                return(false);
            }
            if (IsoFile == string.Empty)
            {
                return(false);
            }
            if (!_Enabled)
            {
                return(false);
            }
            if (!System.IO.File.Exists(_Path))
            {
                return(false);
            }
            DateTime startTime = DateTime.Now;

            System.IO.DriveInfo drive = new System.IO.DriveInfo(_Drive);
            UnMount();

            IsoFile = Utils.RemoveTrailingSlash(IsoFile);
            string strParams;

            if (!_DriveType.Equals(VirtualCloneDrive))
            {
                strParams = String.Format("-mount {0}, {1},\"{2}\"", _DriveType, _DriveNo, IsoFile);
            }
            else
            {
                strParams = String.Format("-mount {0},\"{1}\"", _DriveNo, IsoFile);
            }
            Process p       = Utils.StartProcess(_Path, strParams, true, true);
            int     timeout = 0;

            while ((!p.HasExited || !drive.IsReady || !System.IO.Directory.Exists(_Drive + @"\")) && (timeout < 10000))
            {
                System.Threading.Thread.Sleep(100);
                timeout += 100;
            }
            if (timeout >= 10000)
            {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ASKYESNO, 0, 0, 0, 0, 0, 0);
                msg.Param1  = 200093;
                msg.Param2  = 200094;
                msg.Param3  = 0;
                msg.Param4  = 0;
                msg.Object2 = true;
                GUIWindowManager.SendMessage(msg);
                if (msg.Param1 == 1)
                {
                    while ((!p.HasExited || !drive.IsReady || !System.IO.Directory.Exists(_Drive + @"\")) && (timeout < 60000))
                    {
                        System.Threading.Thread.Sleep(100);
                        timeout += 100;
                    }
                    if (timeout >= 60000)
                    {
                        Log.Error("Mounting failed after {0}s (second timeout). Check your settings.", (int)(timeout / 1000));
                        UnMount();
                        return(false);
                    }
                }
                else
                {
                    Log.Error("Mounting failed after {0}s (first timeout). Check your settings.", (int)(timeout / 1000));
                    UnMount();
                    return(false);
                }
            }
            RemovableDriveHelper.SetMountTime(DateTime.Now);
            VirtualDrive    = _Drive;
            _MountedIsoFile = IsoFile;
            Log.Debug("Mount time: {0}s", String.Format("{0:N}", (DateTime.Now - startTime).TotalSeconds));
            return(true);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// this is actually loading a database view not a directory
        /// and this is done via view handler so parameter is not used
        /// but is needed to override method in base class
        /// </summary>
        /// <param name="strNotUsed">Used to implement method in base class but not used</param>
        protected override void LoadDirectory(string strNotUsed)
        {
            GUIWaitCursor.Show();
            GUIListItem SelectedItem = facadeLayout.SelectedListItem;

            int    previousLevel   = ((MusicViewHandler)handler).PreviousLevel;
            string strSelectedItem = string.Empty;

            if (SelectedItem != null)
            {
                // if there is an item selected and we are loading a new view
                // then store the existing value so when we navigate back up through
                // the view levels we can focus on the item we had selected
                // we can not use current level in the name for the directory history
                // as current level gets updated before LoadDirectory is called
                // therefore use previous level which is set by the music view handler
                // when that returns (ie. that will be level of the view user has
                // made selection from as it has not been cleared yet)
                if (SelectedItem.IsFolder && SelectedItem.Label != "..")
                {
                    m_history.Set(SelectedItem.Label, handler.LocalizedCurrentView + "." +
                                  previousLevel.ToString());
                }
            }

            List <Song> songs;

            if (!((MusicViewHandler)handler).Execute(out songs))
            {
                GUIWaitCursor.Hide();
                Action action = new Action();
                action.wID = Action.ActionType.ACTION_PREVIOUS_MENU;
                GUIGraphicsContext.OnAction(action);
                return;
            }

            GUIControl.ClearControl(GetID, facadeLayout.GetID);
            SwitchLayout();

            List <GUIListItem> itemsToAdd = new List <GUIListItem>();

            TimeSpan totalPlayingTime = new TimeSpan();

            if (previousLevel > handler.CurrentLevel)
            {
                // only need to lookup values when navigating back up through the view
                strSelectedItem = m_history.Get(handler.LocalizedCurrentView + "." + handler.CurrentLevel.ToString());
            }

            #region handle pin protected share

            if (songs.Count > 0) // some songs in there?
            {
                Song song = songs[0];
                if (song.FileName.Length > 0) // does a filename exits
                {
                    foreach (Share share in _shareList)
                    {
                        if (song.FileName.Contains(share.Path)) // compare it with shares
                        {
                            if (share.Pincode != string.Empty)  // does it have a pincode?
                            {
                                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);
                                GUIWindowManager.SendMessage(msg); // ask for the userinput

                                if (msg.Label != share.Pincode)
                                {
                                    songs.Clear();
                                }
                                break;
                            }
                        }
                    }
                }
            }

            #endregion

            if (handler.CurrentLevel > 0)
            {
                // add ".." folder item if not at bottom level of view
                GUIListItem pItem = new GUIListItem("..");
                pItem.Path     = string.Empty;
                pItem.IsFolder = true;
                Util.Utils.SetDefaultIcons(pItem);
                itemsToAdd.Add(pItem);
            }

            // Get current Filter used
            var currentFilter = (FilterDefinition)handler.View.Filters[handler.CurrentLevel];

            for (int i = 0; i < songs.Count; ++i)
            {
                Song        song = songs[i];
                GUIListItem item = new GUIListItem();

                MusicTag tag = new MusicTag();
                tag = song.ToMusicTag();
                item.AlbumInfoTag = song;
                item.MusicTag     = tag;

                if (handler.CurrentLevel + 1 < handler.MaxLevels)
                {
                    item.IsFolder = true;
                    item.Label    = MusicViewHandler.GetFieldValue(song, handler.CurrentLevelWhere);

                    // If we are grouping on a specific value, we have in the Duration field the number of items
                    // Use this in the sort field
                    if (currentFilter.SqlOperator == "group")
                    {
                        item.Label2 = tag.Duration.ToString();
                    }
                    else
                    {
                        SetSortLabel(ref item, CurrentSortMethod, handler.CurrentLevelWhere);
                    }
                }
                else
                {
                    item.IsFolder = false;
                    if (!GUIMusicBaseWindow.SetTrackLabels(ref item, CurrentSortMethod))
                    {
                        item.Label = song.Title;
                    }
                }

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

                item.Path = song.FileName;

                if (!string.IsNullOrEmpty(_currentPlaying) &&
                    item.Path.Equals(_currentPlaying, StringComparison.OrdinalIgnoreCase))
                {
                    item.Selected = true;
                }

                item.Duration        = song.Duration;
                tag.TimesPlayed      = song.TimesPlayed;
                item.Rating          = song.Rating;
                item.Year            = song.Year;
                item.OnRetrieveArt  += new GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
                item.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);
                itemsToAdd.Add(item);
            }

            itemsToAdd.Sort(new MusicSort(CurrentSortMethod, CurrentSortAsc));

            int  iItem        = 0; // used to hold index of item to select
            bool itemSelected = false;
            for (int i = 0; i < itemsToAdd.Count; ++i)
            {
                if (!itemSelected && itemsToAdd[i].Label == strSelectedItem)
                {
                    iItem        = i;
                    itemSelected = true;
                }
                facadeLayout.Add(itemsToAdd[i]);
            }

            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);
            }

            if (itemSelected)
            {
                GUIControl.SelectItemControl(GetID, facadeLayout.GetID, iItem);
            }
            else if (m_iItemSelected >= 0)
            {
                GUIControl.SelectItemControl(GetID, facadeLayout.GetID, m_iItemSelected);
            }
            else
            {
                SelectCurrentItem();
            }

            UpdateButtonStates();
            GUIWaitCursor.Hide();
        }
        /// <summary>
        /// We do not want to change neither the enum nor the previous Create overloaded calls to maintain backward compatibility
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private IPlayer Create(string aFileName, g_Player.MediaType?aMediaType)
        {
            try
            {
                // Set to anything here as it will only be passed if aMediaType is not null
                g_Player.MediaType localType = g_Player.MediaType.Video;
                if (aMediaType != null && aMediaType != g_Player.MediaType.Unknown)
                {
                    localType = (g_Player.MediaType)aMediaType;
                }

                // Get settings only once
                using (Settings xmlreader = new MPSettings())
                {
                    string strAudioPlayer   = xmlreader.GetValueAsString("audioplayer", "playerId", "0"); // BASS Player
                    bool   Vmr9Enabled      = xmlreader.GetValueAsBool("musicvideo", "useVMR9", true);
                    bool   InternalBDPlayer = xmlreader.GetValueAsBool("bdplayer", "useInternalBDPlayer", true);
                    bool   Usemoviecodects  = xmlreader.GetValueAsBool("movieplayer", "usemoviecodects", false);

                    if (aFileName.ToLowerInvariant().IndexOf("rtsp:") >= 0)
                    {
                        if (aMediaType != null)
                        {
                            return(new TSReaderPlayer(localType));
                        }
                        else
                        {
                            return(new TSReaderPlayer());
                        }
                    }

                    if (aFileName.StartsWith("mms:") && aFileName.EndsWith(".ymvp"))
                    {
                        if (Vmr9Enabled)
                        {
                            return(new VideoPlayerVMR9());
                        }
                        else
                        {
                            return(new AudioPlayerWMP9());
                        }
                    }

                    string extension = Path.GetExtension(aFileName).ToLowerInvariant();
                    if (extension == ".bdmv")
                    {
                        if (InternalBDPlayer)
                        {
                            return(new BDPlayer());
                        }
                        else
                        {
                            return(new VideoPlayerVMR9());
                        }
                    }

                    if (extension != ".tv" && extension != ".sbe" && extension != ".dvr-ms" &&
                        aFileName.ToLowerInvariant().IndexOf(".tsbuffer") < 0 && aFileName.ToLowerInvariant().IndexOf("radio.tsbuffer") < 0)
                    {
                        IPlayer newPlayer = GetExternalPlayer(aFileName);
                        if (newPlayer != null)
                        {
                            Log.Info("PlayerFactory: Disabling DX9 exclusive mode");
                            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null);
                            GUIWindowManager.SendMessage(msg);
                            return(newPlayer);
                        }
                    }

                    if (Util.Utils.IsVideo(aFileName))
                    {
                        if (extension == ".tv" || extension == ".sbe" || extension == ".dvr-ms")
                        {
                            //if (extension == ".sbe" || extension == ".dvr-ms")
                            //{
                            //  //GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORDER_STOP_TIMESHIFT, 0, 0, 0, 0, 0, null);
                            //  //GUIWindowManager.SendMessage(msg);
                            //}
                            return(new StreamBufferPlayer9());
                        }
                        if (extension == ".ifo" || Util.VirtualDirectory.IsImageFile(extension))
                        {
                            return(new DVDPlayer9());
                        }
                    }

                    // Use TsReader for timeshift buffer file for TvEngine3 & .ts recordings etc.
                    if (extension == ".tsbuffer" || extension == ".ts" || extension == ".rec")
                    //new support for Topfield recordings
                    {
                        if (aFileName.ToLowerInvariant().IndexOf("radio.tsbuffer") >= 0)
                        {
                            if (aMediaType != null)
                            {
                                return(new BaseTSReaderPlayer(localType));
                            }
                            else
                            {
                                return(new BaseTSReaderPlayer());
                            }
                        }
                        if (aMediaType != null)
                        {
                            if (
                                (GUIWindow.Window)
                                    (Enum.Parse(typeof(GUIWindow.Window), GUIWindowManager.ActiveWindow.ToString())) ==
                                GUIWindow.Window.WINDOW_VIDEOS && Usemoviecodects || (g_Player.IsExtTS && Usemoviecodects))
                            {
                                return(new VideoPlayerVMR9(localType));
                            }
                            else
                            {
                                return(new TSReaderPlayer(localType));
                            }
                        }
                        else
                        {
                            return(new TSReaderPlayer());
                        }
                    }

                    if (!Util.Utils.IsAVStream(aFileName) && Util.Utils.IsVideo(aFileName) && localType != g_Player.MediaType.Music)
                    {
                        if (aMediaType != null)
                        {
                            return(new VideoPlayerVMR9(localType));
                        }
                        else
                        {
                            return(new VideoPlayerVMR9());
                        }
                    }

                    if (Util.Utils.IsCDDA(aFileName))
                    {
                        // Check if, we should use BASS for CD Playback
                        if ((AudioPlayer)Enum.Parse(typeof(AudioPlayer), strAudioPlayer) != AudioPlayer.DShow)
                        {
                            if (BassMusicPlayer.BassFreed)
                            {
                                BassMusicPlayer.Player.InitBass();
                            }

                            return(BassMusicPlayer.Player);
                        }
                        else
                        {
                            return(new AudioPlayerWMP9());
                        }
                    }

                    if (Util.Utils.IsAudio(aFileName) || localType == g_Player.MediaType.Music)
                    {
                        if ((AudioPlayer)Enum.Parse(typeof(AudioPlayer), strAudioPlayer) != AudioPlayer.DShow)
                        {
                            if (BassMusicPlayer.BassFreed)
                            {
                                BassMusicPlayer.Player.InitBass();
                            }

                            return(BassMusicPlayer.Player);
                        }
                        else if (String.Compare(strAudioPlayer, "Windows Media Player 9", true) == 0)
                        {
                            return(new AudioPlayerWMP9());
                        }
                        else
                        {
                            return(new AudioPlayerVMR7());
                        }
                    }

                    // Use WMP Player as Default
                    return(new AudioPlayerWMP9());
                }
            }
            finally
            {
                Log.Debug("PlayerFactory: Successfully created player instance for file - {0}", aFileName);
            }
        }
Ejemplo n.º 29
0
        private string DownloadMainStory()
        {
            // Get the selected item
            GUIListItem item = GetSelectedItem();

            if (item == null)
            {
                return(null);
            }

            feed_details feed = (feed_details)item.MusicTag;

            // Download the story
            string text = null;

            try
            {
                string         data    = string.Empty;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(feed.m_link);
                try
                {
                    // Use the current user in case an NTLM Proxy or similar is used.
                    // request.Proxy = WebProxy.GetDefaultProxy();
                    request.Proxy.Credentials = CredentialCache.DefaultCredentials;
                }
                catch (Exception) {}

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                try
                {
                    using (Stream stream = response.GetResponseStream())
                    {
                        Encoding enc;
                        try
                        {
                            enc = Encoding.GetEncoding(response.ContentEncoding);
                        }
                        catch
                        {
                            // Using Default Encoding
                            enc = Encoding.GetEncoding(m_strSiteEncoding);
                        }
                        using (StreamReader r = new StreamReader(stream, enc))
                        {
                            data = r.ReadToEnd();
                        }
                    }
                    // Convert html to text
                    HtmlToText html = new HtmlToText(data);
                    text = html.ToString().Trim();
                }
                finally
                {
                    if (response != null)
                    {
                        response.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0);
                msg.Param1 = 9;   //my news
                msg.Param2 = 912; //Unable to download latest news
                msg.Param3 = 0;

                string errtxt = ex.Message;
                int    pos    = errtxt.IndexOf(":");
                if (pos != -1)
                {
                    errtxt = errtxt.Substring(pos + 1);
                }
                msg.Label3 = String.Format("{0}\n\n({1})", m_strSiteURL, errtxt);
                GUIWindowManager.SendMessage(msg);

                // Log exception
                Log.Info("ex:{0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
            }

            return(text);
        }
Ejemplo n.º 30
0
        private void Cleanup()
        {
            if (graphBuilder == null)
            {
                return;
            }
            int hr;

            Log.Info("RTSPPlayer:cleanup DShow graph");
            try
            {
                if (VMR9Util.g_vmr9 != null)
                {
                    VMR9Util.g_vmr9.Vmr9MediaCtrl(_mediaCtrl);
                    VMR9Util.g_vmr9.Enable(false);
                }

                if (mediaEvt != null)
                {
                    hr = mediaEvt.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero);
                }

                videoWin = graphBuilder as IVideoWindow;
                if (videoWin != null && GUIGraphicsContext.VideoRenderer != GUIGraphicsContext.VideoRendererType.madVR)
                {
                    videoWin.put_Owner(IntPtr.Zero);
                    videoWin.put_Visible(OABool.False);
                }

                _mediaCtrl    = null;
                mediaEvt      = null;
                _mediaSeeking = null;
                mediaPos      = null;
                basicAudio    = null;
                basicVideo    = null;
                videoWin      = null;
                SubEngine.GetInstance().FreeSubtitles();

                if (graphBuilder != null)
                {
                    DirectShowUtil.RemoveFilters(graphBuilder);
                    if (_rotEntry != null)
                    {
                        _rotEntry.SafeDispose();
                        _rotEntry = null;
                    }
                    DirectShowUtil.FinalReleaseComObject(graphBuilder);
                    graphBuilder = null;
                }

                if (VMR9Util.g_vmr9 != null)
                {
                    VMR9Util.g_vmr9.SafeDispose();
                    VMR9Util.g_vmr9 = null;
                }

                GUIGraphicsContext.form.Invalidate(true);
                _state = PlayState.Init;

                if (_mpegDemux != null)
                {
                    Log.Info("cleanup mpegdemux");
                    DirectShowUtil.FinalReleaseComObject(_mpegDemux);
                    _mpegDemux = null;
                }
                if (_rtspSource != null)
                {
                    Log.Info("cleanup _rtspSource");
                    DirectShowUtil.FinalReleaseComObject(_rtspSource);
                    _rtspSource = null;
                }
                if (_subtitleFilter != null)
                {
                    DirectShowUtil.FinalReleaseComObject(_subtitleFilter);
                    _subtitleFilter = null;
                    if (this.dvbSubRenderer != null)
                    {
                        this.dvbSubRenderer.SetPlayer(null);
                    }
                    this.dvbSubRenderer = null;
                }

                if (vobSub != null)
                {
                    Log.Info("cleanup vobSub");
                    DirectShowUtil.FinalReleaseComObject(vobSub);
                    vobSub = null;
                }
            }
            catch (Exception ex)
            {
                if (VMR9Util.g_vmr9 != null)
                {
                    VMR9Util.g_vmr9.RestoreGuiForMadVr();
                    VMR9Util.g_vmr9.SafeDispose();
                }
                Log.Error("RTSPPlayer: Exception while cleanuping DShow graph - {0} {1}", ex.Message, ex.StackTrace);
            }

            //switch back to directx windowed mode
            Log.Info("RTSPPlayer: Disabling DX9 exclusive mode");
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null);

            GUIWindowManager.SendMessage(msg);
        }