private static AVUrlAssetOptions GetOptionsWithHeaders(IDictionary <string, string> headers)
        {
            var nativeHeaders = new NSMutableDictionary();

            foreach (var header in headers)
            {
                nativeHeaders.Add((NSString)header.Key, (NSString)header.Value);
            }

            var nativeHeadersKey = (NSString)"AVURLAssetHTTPHeaderFieldsKey";

            var options = new AVUrlAssetOptions(NSDictionary.FromObjectAndKey(
                                                    nativeHeaders,
                                                    nativeHeadersKey
                                                    ));

            return(options);
        }
        void SetSource()
        {
            AVAsset asset = null;

            if (Element.Source is UriVideoSource)
            {
                string uri = (Element.Source as UriVideoSource).Uri;
                if (uri.Contains("Bearer="))
                {
                    string[] stringSeparators = new string[] { "Bearer=" };
                    string[] split;


                    split = uri.Split(stringSeparators, StringSplitOptions.None);


                    if (split != null && split.Length == 2)
                    {
                        string bearer = "Bearer " + split[1];
                        if (!String.IsNullOrWhiteSpace(split[0]))
                        {
                            NSMutableDictionary nativeHeaders = new NSMutableDictionary();
                            nativeHeaders.Add(new NSString("Authorization"), (NSString)bearer);

                            var nativeHeadersKey = (NSString)"AVURLAssetHTTPHeaderFieldsKey";

                            var options = new AVUrlAssetOptions(NSDictionary.FromObjectAndKey(
                                                                    nativeHeaders,
                                                                    nativeHeadersKey
                                                                    ));


                            asset = new AVUrlAsset(new NSUrl(uri), options);
                        }
                    }
                }
                else if (!String.IsNullOrWhiteSpace(uri))
                {
                    //asset = AVAsset.FromUrl(new NSUrl(uri));
                    NSUrl url = null;
                    try
                    {
                        string absUri = new Uri(uri).AbsoluteUri;
                        url = new NSUrl(absUri);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                    if (url != null)
                    {
                        asset = AVAsset.FromUrl(url);
                    }
                }
            }
            else if (Element.Source is FileVideoSource)
            {
                string uri = (Element.Source as FileVideoSource).File;

                if (!String.IsNullOrWhiteSpace(uri))
                {
                    asset = AVAsset.FromUrl(new NSUrl(uri));
                }
            }
            else if (Element.Source is ResourceVideoSource)
            {
                string path = (Element.Source as ResourceVideoSource).Path;

                if (!String.IsNullOrWhiteSpace(path))
                {
                    string directory = Path.GetDirectoryName(path);
                    string filename  = Path.GetFileNameWithoutExtension(path);
                    string extension = Path.GetExtension(path).Substring(1);
                    NSUrl  url       = NSBundle.MainBundle.GetUrlForResource(filename, extension, directory);
                    asset = AVAsset.FromUrl(url);
                }
            }

            if (asset != null)
            {
                //ExploreProperties(asset);
                playerItem = new AVPlayerItem(asset);
            }
            else
            {
                playerItem = null;
            }

            player.ReplaceCurrentItemWithPlayerItem(playerItem);

            if (playerItem != null)
            {
                //playbackBufferEmptyObserver = (NSObject)playerItem.AddObserver("playbackBufferEmpty",
                //    NSKeyValueObservingOptions.New,
                //    AVPlayerItem_BufferUpdated);

                playbackLikelyToKeepUpObserver = (NSObject)playerItem.AddObserver("playbackLikelyToKeepUp",
                                                                                  NSKeyValueObservingOptions.New,
                                                                                  AVPlayerItem_BufferUpdated);

                //playbackBufferFullObserver = (NSObject)playerItem.AddObserver("playbackBufferFull",
                //    NSKeyValueObservingOptions.New,
                //    AVPlayerItem_BufferUpdated);

                if (Element.AutoPlay)
                {
                    player.Play();
                }
            }
        }