예제 #1
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
        }
        /// <summary>
        /// Registers element for current media stream source
        /// </summary>
        /// <param name="element"></param>
        private void RegisterWith(MediaElement element)
        {
            if (_extensionManager != null)
            {
                throw new InvalidOperationException("MediaStreamSource is already registered with a media element.");
            }

            _extensionManager = new MediaExtensionManager();
            var config = new Windows.Foundation.Collections.PropertySet();

            // Registration of the scheme handler is global, so we need to get unique scheme so our
            // plugin will be used only for our this one instance of media element.
            string uri = "samplemss-" + element.GetHashCode() + ":";

            config.Add("plugin", new MMSWinRTPlugin(this));
            _extensionManager.RegisterSchemeHandler("MSSWinRTExtension.MediaStreamSchemeHandler", uri, config);

            element.Source = new Uri(uri);
        }
예제 #3
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
        }
예제 #4
0
 public MainPage()
 {
     this.InitializeComponent();
     m_isPlaying = false;
     // TODO: Move this to the Initialization Routine once a connection is established
     // aka move it to "StartCamera" in here... (now it is started and sets up everything at the beginning with fixed parameters
     try
     {
         Uri pathUri = new Uri("vizario://square");
         MediaExtensionManager manager = new MediaExtensionManager();
         manager.RegisterSchemeHandler("Vizario.MediaSource.VizarioSchemeHandler", "vizario:");
         mediaSimple.Source = MediaSource.CreateFromUri(pathUri);
         mediaSimple.MediaPlayer.Play();
     }
     catch (Exception ex)
     {
         if (ex is FormatException)
         {
             // handle exception.
             // For example: Log error or notify user problem with file
         }
     }
 }
예제 #5
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 (!ApiInfo.IsFullExperience)
                {
                    _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;
                }
                else
                {
                    Client.Execute(new AddLogMessage(1, "Unhandled exception:\n" + args.Exception.ToString()));
                }

#if !DEBUG
                Microsoft.AppCenter.Crashes.Crashes.TrackError(args.Exception);
#endif

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

            TaskScheduler.UnobservedTaskException += OnUnobservedException;
            UnhandledException += OnUnhandledException;
#endif
        }
 internal void Unregister()
 {
     _extensionManager = null;
     _service          = null;
 }
예제 #7
0
 public void RegisterSchemeHandler(string scheme)
 {
     MediaExtensionManager.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", scheme, propertySet);
 }
예제 #8
0
 public void RegisterByteStreamHandler(string fileExtension, string mimeType)
 {
     MediaExtensionManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", fileExtension, mimeType, propertySet);
 }