Exemplo n.º 1
0
        async Task <EdgeServerResult> GetEdgeServerAsync(Uri currentStreamUri)
        {
            EdgeServerResult result = null;

            if (EdgeServerMonitor != null)
            {
                try
                {
#if SILVERLIGHT
                    result = await EdgeServerMonitor.GetEdgeServerAsync(currentStreamUri, cts.Token);
#else
                    result = await EdgeServerMonitor.GetEdgeServerAsync(currentStreamUri).AsTask(cts.Token);
#endif
                }
                catch (OperationCanceledException) { throw; }
                catch { /* unable to get edge server info, nothing we can do but continue */ }
            }

            return(result ?? EdgeServerResult.Empty);
        }
        async void player_Loaded(object sender, RoutedEventArgs e)
        {
            var configFileUrl = new Uri("ms-appx:///AudienceInsightConfig.xml");
            
            // Audience Insight config

            var batchingConfig = await BatchingConfigFactory.Load(configFileUrl);

            var dataClient = (RESTDataClient)batchingConfig.BatchAgent;
            dataClient.AdditionalHttpHeaders.Add("Authorization-Token", "{2842C782-562E-4250-A1A2-F66D55B5EA15}");

            var batchinglogAgent = new BatchingLogAgent(batchingConfig);
            var aiLoggingTarget = new AudienceInsightLoggingTarget(batchinglogAgent);

            Microsoft.Media.Analytics.LoggingService.Current.LoggingTargets.Add(aiLoggingTarget);

            // Player Framework analytics config

            var analyticsConfig = await AnalyticsConfig.Load(configFileUrl);
            var analyticsPlugin = new AnalyticsPlugin(analyticsConfig);

            var adaptivePlugin = player.Plugins.OfType<AdaptivePlugin>().FirstOrDefault();
            var adaptiveMonitorFactory = new AdaptiveMonitorFactory(adaptivePlugin.Manager);

            var edgeServerMonitor = new EdgeServerMonitor();

            analyticsPlugin.AdaptiveMonitor = adaptiveMonitorFactory.AdaptiveMonitor;
            analyticsPlugin.EdgeServerMonitor = edgeServerMonitor;

            player.Plugins.Add(analyticsPlugin);

            // Audience Insight ad tracking config

            analyticsPlugin.AnalyticsCollector.LoggingSources.Add(new AdvertisingLoggingSource(player.GetAdHandlerPlugin().AdHandlerController));

            // -or-

            //LoggingService.Current.LoggingSources.Add(new AdvertisingLoggingSource(player.GetAdHandlerPlugin().AdHandlerController));
        
        }