internal void Resume()
        {
            var state = player.State;

            if (state == PlayerState.Idle)
            {
                player.SetSource(new MediaUriSource(uriSource));
                player.Display = new Display(window);
                if (drm != null)
                {
                    drm.Init("XamarinSamplePlayer");
                    drm.Url = uriSource;
                    drm.LicenseRequested += (s, e) =>
                    {
                        Func <string, string> httpPost = param =>
                        {
                            WebRequest req = WebRequest.Create(licenseServer);

                            req.ContentType = "text/xml";
                            req.Method      = "POST";

                            byte[] bytes = Encoding.ASCII.GetBytes(param);
                            req.ContentLength = bytes.Length;

                            using (Stream os = req.GetRequestStream())
                                os.Write(bytes, 0, bytes.Length);

                            return(new StreamReader(req.GetResponse().GetResponseStream()).ReadToEnd().Trim());
                        };

                        string base64DecodedChallengeData = Encoding.ASCII.GetString(Convert.FromBase64String(e.ChallengeData));
                        string licenseData = httpPost(base64DecodedChallengeData);
                        drm.InstallLicense(licenseData);
                    };
                    drm.Open();

                    player.SetDrm(drm);
                }
                loadingUpdater?.Update(true);
                player.PrepareAsync().ContinueWith((t) =>
                {
                    PrepareContinueWithStart(t);
                    if (interruptedPosition > 0)
                    {
                        player.SetPlayPositionAsync(interruptedPosition, true);
                        interruptedPosition = 0;
                    }
                });
            }
            else if (state == PlayerState.Ready || state == PlayerState.Paused)
            {
                player.Start();
            }
        }
        internal PlayerControl(string source, Window window, IUIUpdate loadingUpdater = null, bool usePlayready = false)
        {
            uriSource   = source;
            this.window = window;
            player      = new Tizen.TV.Multimedia.Player();
            player.SetSource(new MediaUriSource(uriSource));

            player.Display            = new Display(window);
            player.PlaybackCompleted += (s, _) =>
            {
                player.Stop();
                Unprepare();
            };
            player.PlaybackInterrupted += (s, _) =>
            {
                Tizen.Log.Info("KEY", "Interrupted");
                interruptedPosition = player.GetPlayPosition();
                Unprepare();
            };
            player.ErrorOccurred += (s, e) =>
            {
                Tizen.Log.Info("KEY", e.ToString());
            };

            if (loadingUpdater != null)
            {
                this.loadingUpdater              = loadingUpdater;
                player.BufferingProgressChanged += BufferingHandler;
            }
            if (usePlayready)
            {
                try
                {
                    drm = DRMManager.CreateDRMManager(DRMType.Playready);
                    drm.AddProperty("LicenseServer", licenseServer);
                    drm.AddProperty("DeleteLicenseAfterUse", true);
                    drm.AddProperty("GetChallenge", true);
                }
                catch (ArgumentException e)
                {
                    if (drm != null)
                    {
                        drm.Dispose();
                    }
                    MessageBox.New(e.ToString());
                }
                catch (PlatformNotSupportedException e)
                {
                    MessageBox.New(e.ToString());
                }
            }
        }