Ejemplo n.º 1
0
        private async void ChromeCastClient_ApplicationStarted(object sender, ChromecastApplication e)
        {
            if (controller == null)
            {
                controller = await ChromecastService.ChromeCastClient.LaunchSharpCaster();
            }
            applicationStarted = true;
            if (connectToUrl != "")
            {
                await controller.LoadMedia(connectToUrl, "video/mp4", null, "BUFFERED", 0D, null, null, null, true, timeStamp);

                mediaLoaded();
            }
        }
Ejemplo n.º 2
0
 private async void Client_ApplicationStarted(object sender, ChromecastApplication e)
 {
     while (_controller == null)
     {
         await Task.Delay(500);
     }
     await _controller.LoadMedia(SWYH.App.CurrentInstance.swyhDevice.ContentDirectory.GetWasapiUris(Audio.AudioFormats.Format.Mp3).FirstOrDefault(), null, null, "BUFFERED", 0D, null);
 }
Ejemplo n.º 3
0
 private static async void Client_ApplicationStarted(object sender, ChromecastApplication e)
 {
     System.Console.WriteLine($"Launched {e.DisplayName}");
     while (_controller == null)
     {
         await Task.Delay(500);
     }
     await _controller.LoadMedia("https://iqmeta.com/chikalicka_bing.mp3", "audio/mp3", null, StreamType.BUFFERED);
 }
Ejemplo n.º 4
0
        private async static void ChromeCastClient_MediaStatusChanged(object sender, MediaStatus e)
        {
            if (e.PlayerState == PlayerState.Playing)
            {
                await Task.Delay(2000);

                await ChromecastService.ChromeCastClient.DisconnectChromecast();

                _controller = null;
                await Task.Delay(5000);

                var devices = await ChromecastService.StartLocatingDevices();

                if (devices.Count == 0)
                {
                    System.Console.WriteLine("No chromecasts found");
                    return;
                }

                var firstChromecast = devices.First();
                System.Console.WriteLine("Device found " + firstChromecast.FriendlyName);
                ChromecastService.ConnectToChromecast(firstChromecast);
                await Task.Delay(5000);

                _controller = await ChromecastService.ChromeCastClient.LaunchSharpCaster();

                await Task.Delay(4000);

                var track = new Track
                {
                    Name           = "English Subtitle",
                    TrackId        = 100,
                    Type           = "TEXT",
                    SubType        = "captions",
                    Language       = "en-US",
                    TrackContentId =
                        "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/tracks/DesigningForGoogleCast-en.vtt"
                };
                while (_controller == null)
                {
                    await Task.Delay(500);
                }

                await _controller.LoadMedia("https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4", "video/mp4", null, "BUFFERED", 0D, null, new[] { track }, new[] { 100 });
            }
        }
Ejemplo n.º 5
0
 public async Task LoadMedia(string title, string description, ImageSource poster)
 {
     Title = title;
     Description = description;
     Poster = poster;
     var track = new Track
     {
         Name = "English Subtitle",
         TrackId = 100,
         Type = "TEXT",
         SubType = "captions",
         Language = "en-US",
         TrackContentId =
             "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/tracks/DesigningForGoogleCast-en.vtt"
     };
     await _controller.LoadMedia("https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4", "video/mp4", null, "BUFFERED", 0D, null, new[] { track }, new[] { 100 });
 }
        private async void ChromeCastClient_ApplicationStarted(object sender, Models.ChromecastStatus.ChromecastApplication e)
        {
            var track = new Track
            {
                Name           = "English Subtitle",
                TrackId        = 100,
                Type           = "TEXT",
                SubType        = "captions",
                Language       = "en-US",
                TrackContentId =
                    "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/tracks/DesigningForGoogleCast-en.vtt"
            };

            if (_controller == null)
            {
                _controller = await ChromecastService.ChromeCastClient.LaunchSharpCaster();
            }

            await _controller.LoadMedia("https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4", "video/mp4", null, "BUFFERED", 0D, null, new[] { track }, new[] { 100 });
        }
Ejemplo n.º 7
0
        private static async void Client_ApplicationStarted(object sender, ChromecastApplication e)
        {
            System.Console.WriteLine($"Application {e.DisplayName} has launched");
            var track = new Track
            {
                Name           = "English Subtitle",
                TrackId        = 100,
                Type           = "TEXT",
                SubType        = "captions",
                Language       = "en-US",
                TrackContentId =
                    "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/tracks/DesigningForGoogleCast-en.vtt"
            };

            while (_controller == null)
            {
                await Task.Delay(500);
            }

            await _controller.LoadMedia("https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4", "video/mp4", null, "BUFFERED", 0D, null, new[] { track }, new[] { 100 });
        }
Ejemplo n.º 8
0
        private async Task LoadMedia(string title)
        {
            while (_controller == null)
            {
                await Task.Delay(500);
            }

            Uri uriResult;
            var isRemote = Uri.TryCreate(_mediaPath, UriKind.Absolute, out uriResult) &&
                           (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

            Track track = null;

            if (!string.IsNullOrEmpty(_subtitleFilePath))
            {
                var message = MimeMessage.Load(_subtitleFilePath);
                _subtitleServer = await _fileServerService.StartStaticFileServer(_subtitleFilePath,
                                                                                 message.BodyParts.FirstOrDefault().ContentType.Name, 9001);

                track = new Track
                {
                    Name           = "Subtitle",
                    TrackId        = 100,
                    Type           = "TEXT",
                    SubType        = "captions",
                    TrackContentId =
                        $"http://{LocalIPAddress()}:9001"
                };
            }

            var metadata = new GenericMediaMetadata {
                title = title
            };

            if (!isRemote)
            {
                try
                {
                    var message = MimeMessage.Load(_mediaPath);
                    _mediaServer =
                        await _fileServerService.StartStreamFileServer(_mediaPath,
                                                                       message.BodyParts.FirstOrDefault().ContentType.Name, 9000);

                    await _controller.LoadMedia($"http://{LocalIPAddress()}:9000",
                                                message.BodyParts.FirstOrDefault().ContentType.Name, metadata, "LIVE",
                                                0D, null, track == null?null : new[] { track }, new[] { 100 });
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    Messenger.Default.Send(
                        new UnhandledExceptionMessage(
                            new PopcornException(LocalizationProviderHelper.GetLocalizedValue <string>("CastFailed"))));
                }
            }
            else
            {
                if (track != null)
                {
                    await _controller.LoadMedia(_mediaPath, "video/mp4", metadata, "BUFFERED", 0D,
                                                null, new[] { track },
                                                new[] { 100 });
                }
                else
                {
                    await _controller.LoadMedia(_mediaPath, "video/mp4", metadata, "BUFFERED");
                }
            }
        }