Inheritance: IJsonConvertible
        /// <summary>
        /// Call Start API and initialize some parameters.
        /// </summary>
        internal void MediaStarted()
        {                
            var durationFromPlayer = GetDuration(_smfPlayer);
            var fileNameFromPlayer = GetFilename(_smfPlayer);
            var titleFromPlayer = GetTitle(_smfPlayer);
            if (string.IsNullOrEmpty(titleFromPlayer))
            {
                titleFromPlayer = fileNameFromPlayer;
            }                    

            // Add properties from Player.
            if (ContentProperties == null)
            {
                ContentProperties = new ContentProperties();
            }
            ContentProperties.SetDefaultFilename(fileNameFromPlayer);
            ContentProperties.SetDefaultContentTitle(titleFromPlayer);
            ContentProperties.SetDefaultContentDuration(durationFromPlayer);

            var properties = ContentProperties.ConvertToJson();


            // Update Url
            if (_smfPlayer != null && _smfPlayer.CurrentPlaylistItem != null)
            {
                SetUrl(_smfPlayer.CurrentPlaylistItem.MediaSourceText);
            }

            if (_changePlaylist)
            {
                YouboraApi.GetData(System, DefaultPluginVersion, dataRoot =>
                {
                    // New playlist - Renew code
                    Code = dataRoot.Data.Code;
                    _previousCode = Code;

                    YouboraAvPlayerLog("Data", "YouboraAvPlayer Data ChangePlayList - Host: " + Host + ", Code: " + Code, LogType.Data);
                    
                    // Start using new code
                    Start(System, UserId, DefaultPluginVersion, Code, Url, IsLive, properties, Referer, PingTime);
                });

                _changePlaylist = false;
            }
            else
            {
                var newCode = _playListItemCounter > 1 ? _previousCode + "_" + (_playListItemCounter - 1) : _previousCode;
                Code = newCode;

                //Debug.WriteLine("Renew code: {0}", newCode);                

                // Start
                Start(System, UserId, DefaultPluginVersion, newCode, Url, IsLive, properties, Referer, PingTime);
            }
        }
 public YouboraAvPlayer()
 {
     OptionalParams = new OptionalParams();
     ContentProperties = new ContentProperties();
 }
        /// <summary>
        /// Reports a player error.
        /// </summary>
        /// <param name="errorCode">Player's error numerical code</param>
        public void Error(string errorCode)
        {
            var codeNumber = Regex.Match(errorCode, @"\d+").Value;
            var bitrate = GetBitrate(_smfPlayer);
            var durationFromPlayer = GetDuration(_smfPlayer);
            var filenameFromPlayer = GetFilename(_smfPlayer);
            var titleFromPlayer = GetTitle(_smfPlayer);
            if (string.IsNullOrEmpty(titleFromPlayer))
            {
                titleFromPlayer = filenameFromPlayer;
            }

            // Add properties from Player.
            if (ContentProperties == null)
            {
                ContentProperties = new ContentProperties();
            }
            ContentProperties.SetDefaultFilename(filenameFromPlayer);
            ContentProperties.SetDefaultContentTitle(titleFromPlayer);
            ContentProperties.SetDefaultContentDuration(durationFromPlayer);

            // Create properties
            var properties = ContentProperties.ConvertToJson();            

            var optionalParamQueryString = (OptionalParams != null) ? OptionalParams.GetQueryString() : string.Empty;

            YouboraApi.Error(codeNumber, Code, errorCode, Url,
                    System, IsLive, properties, UserId, string.Empty, bitrate, PingTime, PluginVersion,
                    Convert.ToInt64(durationFromPlayer), optionalParamQueryString,
                    result =>
                    {
                        YouboraAvPlayerLog("Error", "YouboraAvPlayer Error - Exception Message: " + errorCode,
                            LogType.Error);
                    });
        }