public SMFPlayer()
        {
            DefaultStyleKey = typeof(SMFPlayer);

            _logger = new Logger();
            _videoDoubleClickMonitor = new DoubleClickMonitor();
            _positionTimer = new DispatcherTimer();

            Playlist = new ObservableCollection<PlaylistItem>();
            HeuristicsPluginRequiredMetadata = new MetadataCollection();
            GlobalConfigMetadata = new MetadataCollection();

            _captionManager = new MediaMarkerManager<CaptionRegion>
            {
                SeekingSearchWindow = TimeSpan.FromMilliseconds(DefaultMaximumCaptionSeekSearchWindowMillis)
            };
            _captionManager.MarkerLeft += CaptionManager_MarkerLeft;
            _captionManager.MarkerReached += CaptionManager_MarkerReached;

            _timelineMarkerManager = new TimelineMarkerManager();
            _timelineMarkerManager.MarkerLeft += MarkerManager_MarkerLeft;
            _timelineMarkerManager.MarkerReached += MarkerManager_MarkerReached;
            _timelineMarkerManager.MarkerSkipped += MarkerManager_MarkerSkipped;

            _adMarkerManager = new AdMarkerManager(this);
            _adMarkerManager.MarkerLeft += AdManager_MarkerLeft;
            _adMarkerManager.MarkerReached += AdManager_MarkerReached;
            _adMarkerManager.MarkerSkipped += AdManager_MarkerSkipped;

            if (!IsInDesignMode)
            {
#if !WINDOWS_PHONE && !OOB
                _offlineManager = new OfflineManager();
#endif
                PluginsManager = new PluginsManager();
                _logger.LogWriteSuccessful += Logger_LogWriteSuccessful;
                _logger.LogWriteErrorOccurred += Logger_LogWriteErrorOccurred;

                _videoDoubleClickMonitor.ElementDoubleClicked += (s, e) => MediaPresenterElement_DoubleClicked();
                _positionTimer.Interval = PositionUpdateInterval;
                _positionTimer.Tick += (s, e) => UpdateTimelinePositions();

#if !PROGRAMMATICCOMPOSITION
                PluginsManager.AddExternalPackageDownloadProgressChanged += PluginsManager_AddExternalPackageDownloadProgressChanged;
                PluginsManager.AddExternalPackageCompleted += PluginsManager_AddExternalPackageCompleted;
                PluginsManager.AddExternalPackageFailed += PluginsManager_AddExternalPackageFailed;
#endif

#if !WINDOWS_PHONE && !FULLSCREEN
                IsFullScreen = Application.Current.Host.Content.IsFullScreen;
                Application.Current.Host.Content.FullScreenChanged += Application_FullScreenChanged;
#endif
            }
        }
 private void PluginsManager_AddExternalPackageFailed(PluginsManager pluginsManager, Uri xapLocation,
                                                      Exception error)
 {
     string logMessage = string.Format(SilverlightMediaFrameworkResources.AddExternalPackageFailedLogMessage,
                                       xapLocation, error.Message);
     SendLogEntry(KnownLogEntryTypes.AddExternalPluginsFailed, LogLevel.Warning, logMessage);
     AddExternalPluginsFailed.IfNotNull(i => i(this, new CustomEventArgs<Exception>(error)));
 }
 private void PluginsManager_AddExternalPackageCompleted(PluginsManager pluginsManager, Uri xapLocation)
 {
     string logMessage = string.Format(SilverlightMediaFrameworkResources.AddExternalPackageCompletedLogMessage,
                                       xapLocation);
     SendLogEntry(message: logMessage, type: KnownLogEntryTypes.AddExternalPluginsCompleted);
     OnAddExternalPackageCompleted();
     AddExternalPluginsCompleted.IfNotNull(i => i(this, EventArgs.Empty));
 }
 private void PluginsManager_AddExternalPackageDownloadProgressChanged(PluginsManager pluginsManager,
                                                                       Uri xapLocation,
                                                                       DownloadProgressChangedEventArgs e)
 {
     string logMessage =
         string.Format(SilverlightMediaFrameworkResources.AddExternalPackageDownloadProgressChangedLogMessage,
                       xapLocation, e.ProgressPercentage);
     SendLogEntry(KnownLogEntryTypes.AddExternalPluginsDownloadProgressChanged, LogLevel.Warning, logMessage);
     AddExternalPackageDownloadProgressChanged.IfNotNull(i => i(this, new ExternalPackageDownloadProgressInfo { XapLocation = xapLocation, DownloadProgress = e }));
 }