Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            if (e.Parameter is DialReceiverActivatedEventArgs)
            {
                DialReceiverActivatedEventArgs activationArgs = (DialReceiverActivatedEventArgs)e.Parameter;

                //Parse the DIAL arguments from the activation arguments
                DialLaunchArguments dialArgs = DialLaunchArguments.Parse(activationArgs.Arguments);

                // Get the list of available Azure videos.
                AzureDataProvider dataProvider = new AzureDataProvider();
                // Get the vide that is playing
                video = dataProvider.GetFromID(dialArgs.VideoId);

                //Subscribe to player events
                player.MediaOpened         += Player_MediaOpened;
                player.MediaFailed         += Player_MediaFailed;
                player.CurrentStateChanged += Player_CurrentStateChanged;

                //Set the source on the player
                rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
                this.player.Source = video.VideoLink;

                player.Position = dialArgs.Position;
            }
            else
            {
                rootPage.NotifyUser("Scenario was not activated using DIAL", NotifyType.ErrorMessage);
            }
        }
        public Scenario01()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetFromID("BigBuckBunnyTrailer");
            this.player.Source = video.VideoLink;

            //Set the source on the MediaElement
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);



            // Use the compat version of the transport controls
            this.player.TransportControls.IsCompact = true;

            //Start Playback
            player.Play();
        }
Exemplo n.º 3
0
        public Scenario3()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            // Get the list of available Azure videos.
            AzureDataProvider    dataProvider = new AzureDataProvider();
            List <VideoMetaData> videos       = dataProvider.GetAll(MAX_RESULTS);
            Random indexRandomizer            = new Random();

            // Pick a random video
            video = videos[indexRandomizer.Next(0, videos.Count - 1)];

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            //Set the look and feel of the TransportControls
            player.TransportControls.IsCompact = true;

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            player.Source = video.VideoLink;

            this.dial_launch_args_textbox.Text = string.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id);
        }
Exemplo n.º 4
0
        public Scenario2()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            // Get the list of available Azure videos.
            AzureDataProvider    dataProvider = new AzureDataProvider();
            List <VideoMetaData> videos       = dataProvider.GetAll(MAX_RESULTS);
            Random indexRandomizer            = new Random();

            // Pick a random video
            video = videos[indexRandomizer.Next(0, videos.Count - 1)];

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            //Set the look and feel of the TransportControls
            player.TransportControls.IsCompact = true;

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            player.Source = video.VideoLink;

            //Configure the DIAL launch arguments for the current video
            this.dial_launch_args_textbox.Text = string.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id);

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DevicePicker();

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up device disconnected event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            ////Set the Appearence of the picker
            //picker.Appearance.BackgroundColor = Colors.Black;
            //picker.Appearance.ForegroundColor = Colors.White;
            //picker.Appearance.SelectedAccentColor = Colors.LightGray;
            //picker.Appearance.SelectedForegroundColor = Colors.White;
            //picker.Appearance.AccentColor = Colors.White;
            //picker.Appearance.SelectedAccentColor = Colors.White;

            pvb.ProjectionStopping += Pvb_ProjectionStopping;
        }
Exemplo n.º 5
0
 private void SetDataProvider(string account, string key, bool isUsehttps)
 {
     try
     {
         DataProvider = new AzureDataProvider(account, key, isUseHttps: true);
     }
     catch (Exception ex)
     {
         //TODO: log this exception
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 6
0
 private void SetDataProvider(bool isDeveloperAccount)
 {
     try
     {
         DataProvider = new AzureDataProvider(isDeveloperAccount);
     }
     catch (Exception ex)
     {
         //TODO: log this exception
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 7
0
        public Scenario06()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            this.player.Source    = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Configure the DIAL launch arguments for the current video
            this.dial_launch_args_textbox.Text = string.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id);

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DevicePicker();

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up device disconnected event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            //Add the DIAL Filter, so that the application only shows DIAL devices that have the application installed or advertise that they can install them.
            //BUG: picker.Filter.SupportedDeviceSelectors.Add(DialDevice.GetDeviceSelector(this.dial_appname_textbox.Text));
            picker.Filter.SupportedDeviceSelectors.Add("System.Devices.DevObjectType:=6 AND System.Devices.AepContainer.ProtocolIds:~~{0E261DE4-12F0-46E6-91BA-428607CCEF64} AND System.Devices.AepContainer.Categories:~~Multimedia.ApplicationLauncher.DIAL");

            //Add the CAST API Filter, so that the application only shows Miracast, Bluetooth, DLNA devices that can render the video
            // BUG: picker.Filter.SupportedDeviceSelectors.Add(await CastingDevice.GetDeviceSelectorFromCastingSourceAsync(player.GetAsCastingSource()));
            // BUG: picker.Filter.SupportedDeviceSelectors.Add(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video));
            picker.Filter.SupportedDeviceSelectors.Add("System.Devices.InterfaceClassGuid:=\"{D0875FB4-2196-4c7a-A63D-E416ADDD60A1}\"" + " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True");

            //Add projection manager filter
            picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            pvb.ProjectionStopping += Pvb_ProjectionStopping;
        }
Exemplo n.º 8
0
        public Scenario02()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            player.Source         = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new CastingDevicePicker();

            // Generate the filter based on the content in the MediaElement
            picker.Filter.SupportedCastingSources.Add(player.GetAsCastingSource());

            //Hook up device selected event
            picker.CastingDeviceSelected += Picker_CastingDeviceSelected;

            //Hook up device disconnected event
            picker.CastingDevicePickerDismissed += Picker_CastingDevicePickerDismissed;

            //Set the Appearence of the picker
            picker.Appearance.BackgroundColor = Colors.Black;
            picker.Appearance.ForegroundColor = Colors.White;
            picker.Appearance.AccentColor     = Colors.Gray;

            picker.Appearance.SelectedAccentColor = Colors.Gray;

            picker.Appearance.SelectedForegroundColor = Colors.White;
            picker.Appearance.SelectedBackgroundColor = Colors.Black;
        }
Exemplo n.º 9
0
        public Scenario03()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            this.player.PosterSource = new BitmapImage(video.Thumbnail);
            this.player.Source       = video.VideoLink;

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            //Configure the DIAL launch arguments for the current video
            this.dial_launch_args_textbox.Text = string.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id);

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DialDevicePicker();

            //Add the DIAL Filter, so that the application only shows DIAL devices that have
            // the application installed or advertise that they can install them.
            picker.Filter.SupportedAppNames.Add(this.dial_appname_textbox.Text);

            //Hook up device selected event
            picker.DialDeviceSelected += Picker_DialDeviceSelected;

            //Hook up the picker disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up the picker dismissed event
            picker.DialDevicePickerDismissed += Picker_DialDevicePickerDismissed;
        }
        public Scenario05()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get an Azure hosted video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();

            //Set the source on the player
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
            this.player.Source    = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Subscribe for the clicked event on the custom cast button
            ((MediaTransportControlsWithCustomCastButton)this.player.TransportControls).CastButtonClicked += TransportControls_CastButtonClicked;

            // Instantiate the Device Picker
            picker = new DevicePicker();

            // Get the device selecter for Miracast devices
            picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector());

            //Hook up device selected event
            picker.DeviceSelected += Picker_DeviceSelected;

            //Hook up device disconnected event
            picker.DisconnectButtonClicked += Picker_DisconnectButtonClicked;

            //Hook up picker dismissed event
            picker.DevicePickerDismissed += Picker_DevicePickerDismissed;

            // Hook up the events that are received when projection is stoppped
            pvb.ProjectionStopping += Pvb_ProjectionStopping;
        }
Exemplo n.º 11
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;
            player.MediaEnded          += Player_MediaEnded;

            if (e.Parameter is DialReceiverActivatedEventArgs)
            {
                DialReceiverActivatedEventArgs activationArgs = (DialReceiverActivatedEventArgs)e.Parameter;

                //Parse the DIAL arguments from the activation arguments
                DialLaunchArguments dialArgs = DialLaunchArguments.Parse(activationArgs.Arguments);

                // Get the list of available Azure videos.
                AzureDataProvider dataProvider = new AzureDataProvider();
                // Get the vide that is playing
                video = dataProvider.GetFromID(dialArgs.VideoId);
                //Set the source on the player
                rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);
                this.player.Source    = video.VideoLink;
                this.LicenseText.Text = "License: " + video.License;

                player.Position = dialArgs.Position;
            }
            else
            {
                StorageFile localVideo = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/casting.mp4"));

                var stream = await localVideo.OpenAsync(FileAccessMode.Read);

                this.player.SetSource(stream, localVideo.FileType);
            }
        }
Exemplo n.º 12
0
        public Scenario01()
        {
            this.InitializeComponent();

            rootPage = MainPage.Current;

            //Subscribe to player events
            player.MediaOpened         += Player_MediaOpened;
            player.MediaFailed         += Player_MediaFailed;
            player.CurrentStateChanged += Player_CurrentStateChanged;

            // Get a video
            AzureDataProvider dataProvider = new AzureDataProvider();

            video = dataProvider.GetRandomVideo();
            this.player.Source    = video.VideoLink;
            this.LicenseText.Text = "License: " + video.License;

            //Set the source on the MediaElement
            rootPage.NotifyUser(string.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage);

            // Use the compat version of the transport controls
            this.player.TransportControls.IsCompact = true;
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Worker for Common Runtime for Applications (CRA) [http://github.com/Microsoft/CRA]");
                Console.WriteLine("Usage: CRA.Worker.exe instancename (e.g., instance1) port (e.g., 11000) [ipaddress (null for default)] [secure_network_assembly_name secure_network_class_name]");
                return;
            }

            string        ipAddress = "";
            string        storageConnectionString = null;
            IDataProvider dataProvider            = null;
            int           connectionsPoolPerWorker;
            string        connectionsPoolPerWorkerString = null;

            if (args.Length < 3 || args[2] == "null")
            {
                ipAddress = GetLocalIPAddress();
            }
            else
            {
                ipAddress = args[2];
            }


#if !DOTNETCORE
            storageConnectionString = ConfigurationManager.AppSettings.Get("AZURE_STORAGE_CONN_STRING");
#endif

            if (storageConnectionString == null)
            {
                storageConnectionString = Environment.GetEnvironmentVariable("AZURE_STORAGE_CONN_STRING");
            }

            if (storageConnectionString != null)
            {
                dataProvider = new AzureDataProvider(storageConnectionString);
            }
            else if (storageConnectionString == null)
            {
                dataProvider = new FileDataProvider();
            }

#if !DOTNETCORE
            connectionsPoolPerWorkerString = ConfigurationManager.AppSettings.Get("CRA_WORKER_MAX_CONN_POOL");
#endif
            if (connectionsPoolPerWorkerString != null)
            {
                try
                {
                    connectionsPoolPerWorker = Convert.ToInt32(connectionsPoolPerWorkerString);
                }
                catch
                {
                    throw new InvalidOperationException("Maximum number of connections per CRA worker is wrong. Use appSettings in your app.config to provide this using the key CRA_WORKER_MAX_CONN_POOL.");
                }
            }
            else
            {
                connectionsPoolPerWorker = 1000;
            }

            ISecureStreamConnectionDescriptor descriptor = null;
            if (args.Length > 3)
            {
                if (args.Length < 5)
                {
                    throw new InvalidOperationException("Invalid secure network info provided");
                }

                Type type;
                if (args[3] != "null")
                {
                    var assembly = Assembly.Load(args[3]);
                    type = assembly.GetType(args[4]);
                }
                else
                {
                    type = Type.GetType(args[4]);
                }

                descriptor = (ISecureStreamConnectionDescriptor)Activator.CreateInstance(type);
            }

            var worker = new CRAWorker(
                args[0],
                ipAddress,
                Convert.ToInt32(args[1]),
                dataProvider,
                descriptor,
                connectionsPoolPerWorker);

            worker.Start();
        }