private void _initialiseMediaExtensionManager()
        {
            var plugins = new MediaExtensionManager();

            plugins.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml");
            plugins.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml");
            plugins.RegisterByteStreamHandler("Windows.Media.Protection.PlayReady.PlayReadyByteStreamHandler", ".pyv", "");
            plugins.RegisterByteStreamHandler("Windows.Media.Protection.PlayReady.PlayReadyByteStreamHandler", ".pya", "");
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Locator.Configure(/*session*/);

            if (SettingsService.Current.Appearance.RequestedTheme != ElementTheme.Default)
            {
                RequestedTheme = SettingsService.Current.Appearance.GetCalculatedApplicationTheme();
            }

            InitializeComponent();

            try
            {
                if (!string.Equals(AnalyticsInfo.VersionInfo.DeviceFamily, "Windows.Desktop"))
                {
                    _mediaExtensionManager = new MediaExtensionManager();
                    _mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.Media.OpusByteStreamHandler", ".ogg", "audio/ogg");
                    _mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.Media.OpusByteStreamHandler", ".oga", "audio/ogg");
                }
            }
            catch
            {
                // User won't be able to play and record voice messages, but it still better than not being able to use the app at all.
            }

            InactivityHelper.Detected += Inactivity_Detected;

            UnhandledException += (s, args) =>
            {
                if (args.Exception is NotSupportedException)
                {
                    args.Handled = true;
                }

                //try
                //{
                //    await new MessagePopup(args.Exception?.ToString() ?? string.Empty, "Unhandled exception").ShowQueuedAsync();
                //}
                //catch { }
            };

#if !DEBUG
            Microsoft.AppCenter.AppCenter.Start(Constants.AppCenterId,
                                                typeof(Microsoft.AppCenter.Analytics.Analytics),
                                                typeof(Microsoft.AppCenter.Crashes.Crashes));

            string deviceFamilyVersion = AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
            ulong  version             = ulong.Parse(deviceFamilyVersion);
            ulong  major = (version & 0xFFFF000000000000L) >> 48;
            ulong  minor = (version & 0x0000FFFF00000000L) >> 32;
            ulong  build = (version & 0x00000000FFFF0000L) >> 16;

            Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{major}.{minor}.{build}");
            Microsoft.AppCenter.Analytics.Analytics.TrackEvent(AnalyticsInfo.VersionInfo.DeviceFamily);
#endif
        }
示例#3
0
        /// <summary>Initializes the media extension manager so we can handle PlayReady protected content.</summary>
        private void InitializeMediaExtensionManager()
        {
            var plugins = new MediaExtensionManager();

            // Add support for IIS Smooth Streaming Manifests
            plugins.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml");
            plugins.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml");

            // Add support for PlayReady video and audio files
            plugins.RegisterByteStreamHandler("Microsoft.Media.Protection.PlayReady.PlayReadyByteStreamHandler", ".pyv", "");
            plugins.RegisterByteStreamHandler("Microsoft.Media.Protection.PlayReady.PlayReadyByteStreamHandler", ".pya", "");
        }
        public MainPage()
        {
            this.InitializeComponent();


            // Gets the default instance of AdaptiveSourceManager which manages Smooth Streaming media sources.
            adaptiveSourceManager = AdaptiveSourceManager.GetDefault();

            //Property sets are used to indicate what properties of an item or folder should be loaded when binding to an existing item or folder or when loading an item or folder's properties.
            // Sets property key value to AdaptiveSourceManager default instance.
            // {A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}" must be hardcoded.
            propertySet["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = adaptiveSourceManager;
            //The MediaElement control does not support Smooth Streaming content out-of-box. To enable the Smooth Streaming support,
            //you must register the Smooth Streaming byte-stream handler by file name extension and MIME type. To register, you use the
            //MediaExtensionManager.RegisterByteStremHandler method of the Windows.Media namespace.


            // Registers Smooth Streaming byte-stream handler for ".ism" extension and,
            // "text/xml" and "application/vnd.ms-ss" mime-types and pass the propertyset.
            // http://*.ism/manifest URI resources will be resolved by Byte-stream handler.
            extensions.RegisterByteStreamHandler(
                "Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler",
                ".ism",
                "text/xml",
                propertySet);
            extensions.RegisterByteStreamHandler(
                "Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler",
                ".ism",
                "application/vnd.ms-sstr+xml",
                propertySet);
            //The source resolver takes a URL or byte stream and creates the appropriate media source for that content.
            //The source resolver is the standard way for the applications to create media sources.


            //subscribes to the adaptive source open event
            adaptiveSourceManager.AdaptiveSourceOpenedEvent += new AdaptiveSourceOpenedEventHandler(mediaElement_AdaptiveSourceOpened);
            //adaptiveSourceManager.AdaptiveSourceStatusUpdated += new AdaptiveSourceClosedEventHandler(mediaElement_AdaptiveSourceStatusUpdated);
            adaptiveSourceManager.AdaptiveSourceStatusUpdatedEvent += new AdaptiveSourceStatusUpdatedEventHandler(mediaElement_AdaptiveSourceStatusUpdated);
            adaptiveSourceManager.AdaptiveSourceStatusUpdatedEvent += adaptiveSourceManager_AdaptiveSourceStatusUpdatedEvent;
            //adaptiveSourceManager.AdaptiveSourceClosedEvent += new AdaptiveSourceClosedEventArgs(mediaElement_AdaptiveSourceClosed);

            //required to subscribe to the media element events
            mediaElement.MediaOpened += MediaOpened;
            mediaElement.MediaEnded  += MediaEnded;
            mediaElement.MediaFailed += MediaFailed;

            //code for the media player slider
            _dispatcher = Window.Current.Dispatcher;
            PointerEventHandler pointerpressedhandler = new PointerEventHandler(sliderProgress_PointerPressed);
            //sliderProgress.AddHandler(Control.PointerPressedEvent, pointerpressedhandler, true);
        }
示例#5
0
        public MainPage()
        {
            this.InitializeComponent();

            // Gets the default instance of AdaptiveSourceManager which manages Smooth
            //Streaming media sources.
            adaptiveSourceManager = AdaptiveSourceManager.GetDefault();
            // Sets property key value to AdaptiveSourceManager default instance.
            // {A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}" must be hardcoded.
            propertySet["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = adaptiveSourceManager;

            // Registers Smooth Streaming byte-stream handler for “.ism” extension and,
            // "text/xml" and "application/vnd.ms-ss" mime-types and pass the propertyset.
            // http://*.ism/manifest URI resources will be resolved by Byte-stream handler.
            extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", propertySet);
            extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-ss", propertySet);
            extensions.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", propertySet);
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            if (ApplicationSettings.Current.RequestedTheme != ElementTheme.Default)
            {
                RequestedTheme = ApplicationSettings.Current.RequestedTheme == ElementTheme.Dark ? ApplicationTheme.Dark : ApplicationTheme.Light;
            }

            CustomXamlResourceLoader.Current = new XamlResourceLoader();

            InitializeComponent();

            _uiSettings = new UISettings();
            _uiSettings.ColorValuesChanged += ColorValuesChanged;

            m_mediaExtensionManager = new MediaExtensionManager();
            m_mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.OpusByteStreamHandler", ".ogg", "audio/ogg");

            if (SettingsHelper.SwitchAccount >= 0)
            {
                SettingsHelper.SelectedAccount = SettingsHelper.SwitchAccount;
                SettingsHelper.SwitchAccount   = -1;
            }

            FileUtils.CreateTemporaryFolder();

            InactivityHelper.Detected += Inactivity_Detected;

            UnhandledException += async(s, args) =>
            {
                args.Handled = true;

                try
                {
                    await new TLMessageDialog(args.Exception?.ToString() ?? string.Empty, "Unhandled exception").ShowQueuedAsync();
                }
                catch { }
            };

#if !DEBUG
            HockeyClient.Current.Configure("7d36a4260af54125bbf6db407911ed3b",
                                           new TelemetryConfiguration()
            {
                EnableDiagnostics = true,
                Collectors        = WindowsCollectors.Metadata |
                                    WindowsCollectors.Session |
                                    WindowsCollectors.UnhandledException
            });
#endif
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            if (ApplicationSettings.Current.RequestedTheme != ElementTheme.Default)
            {
                RequestedTheme = ApplicationSettings.Current.RequestedTheme == ElementTheme.Dark ? ApplicationTheme.Dark : ApplicationTheme.Light;
            }

#if DEBUG
            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en";
#endif

            Locator.Configure();
            UnigramContainer.Current.ResolveType <IGenerationService>();
            CustomXamlResourceLoader.Current = new XamlResourceLoader();

            InitializeComponent();

            _uiSettings = new UISettings();
            _uiSettings.ColorValuesChanged += ColorValuesChanged;

            m_mediaExtensionManager = new MediaExtensionManager();
            m_mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.OpusByteStreamHandler", ".ogg", "audio/ogg");

            InactivityHelper.Detected += Inactivity_Detected;

            UnhandledException += async(s, args) =>
            {
                args.Handled = true;

                try
                {
                    await new TLMessageDialog(args.Exception?.ToString() ?? string.Empty, "Unhandled exception").ShowQueuedAsync();
                }
                catch { }
            };

#if !DEBUG
            HockeyClient.Current.Configure(Constants.HockeyAppId,
                                           new TelemetryConfiguration()
            {
                EnableDiagnostics = true,
                Collectors        = WindowsCollectors.Metadata |
                                    WindowsCollectors.Session |
                                    WindowsCollectors.UnhandledException
            });
#endif
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App(int session)
        {
            if (!SettingsService.Current.Appearance.RequestedTheme.HasFlag(TelegramTheme.Default))
            {
                RequestedTheme = SettingsService.Current.Appearance.RequestedTheme.HasFlag(TelegramTheme.Dark) ? ApplicationTheme.Dark : ApplicationTheme.Light;
            }

#if DEBUG
            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en";
#endif

            Locator.Configure(/*session*/);

            InitializeComponent();

            _uiSettings = new UISettings();

            m_mediaExtensionManager = new MediaExtensionManager();
            m_mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.OpusByteStreamHandler", ".ogg", "audio/ogg");

            InactivityHelper.Detected += Inactivity_Detected;

            UnhandledException += async(s, args) =>
            {
                args.Handled = true;

                try
                {
                    await new TLMessageDialog(args.Exception?.ToString() ?? string.Empty, "Unhandled exception").ShowQueuedAsync();
                }
                catch { }
            };

#if !DEBUG
            HockeyClient.Current.Configure(Constants.HockeyAppId,
                                           new TelemetryConfiguration()
            {
                EnableDiagnostics = true,
                Collectors        = WindowsCollectors.Metadata |
                                    WindowsCollectors.Session |
                                    WindowsCollectors.UnhandledException
            });
#endif
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            InitializeComponent();

            _uiSettings.ColorValuesChanged += ColorValuesChanged;

            m_mediaExtensionManager = new MediaExtensionManager();
            m_mediaExtensionManager.RegisterByteStreamHandler("Unigram.Native.OpusByteStreamHandler", ".ogg", "audio/ogg");

            if (SettingsHelper.SwitchGuid != null)
            {
                SettingsHelper.SessionGuid = SettingsHelper.SwitchGuid;
                SettingsHelper.SwitchGuid  = null;
            }

            FileUtils.CreateTemporaryFolder();

            UnhandledException += async(s, args) =>
            {
                args.Handled = true;

                try
                {
                    await new TLMessageDialog(args.Exception?.ToString() ?? string.Empty, "Unhandled exception").ShowQueuedAsync();
                }
                catch { }
            };

#if !DEBUG
            HockeyClient.Current.Configure("7d36a4260af54125bbf6db407911ed3b",
                                           new TelemetryConfiguration()
            {
                EnableDiagnostics = true,
                Collectors        = WindowsCollectors.Metadata |
                                    WindowsCollectors.Session |
                                    WindowsCollectors.UnhandledException
            });
#endif
        }
示例#10
0
 public void RegisterByteStreamHandler(string fileExtension, string mimeType)
 {
     MediaExtensionManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", fileExtension, mimeType, propertySet);
 }