示例#1
0
        /// <summary>
        /// Get ad URL and call to that.
        /// </summary>
        /// <returns></returns>
        private IEnumerator DoAdRequest()
        {
            string adNetworkUrl;

            if (m_wrapperList.Count > 0)
            {
                adNetworkUrl = m_wrapperList[m_wrapperList.Count - 1].VASTAdTagURI;
            }
            else
            {
                if (VSettings.PrerollAdProviders.Count > 0 && !VSettings.IsPreRollAdPlayed)
                {
                    adNetworkUrl = VSettings.PrerollAdProviders[m_adUrlIndex];
                }
                else if (VSettings.MidrollAdProviders.Count > 0)
                {
                    adNetworkUrl = VSettings.MidrollAdProviders[m_adUrlIndex];
                    m_isMidRoll  = true;
                }
                else
                {
                    Error("No ad providers", false);
                    yield break;
                }

                // Special treatment for URL containing value
                if (adNetworkUrl.Contains("<<<EXTRA>>>"))
                {
                    adNetworkUrl = adNetworkUrl.Replace("<<<EXTRA>>>", VUtils.GetTimestamp().ToString());
                    Debug.Log(adNetworkUrl);
                }
            }

            m_isWaitingResponse = true;
            if (!m_network.CallGet(adNetworkUrl, AdRequestCallback))
            {
                m_isWaitingResponse = false;
                Error("Call failed to " + adNetworkUrl, true);
                TryNext();
            }

            float timeOut = Time.realtimeSinceStartup + VSettings.BaseTimeOut;

            while (m_isWaitingResponse)
            {
                if (Time.realtimeSinceStartup > timeOut)
                {
                    m_isWaitingResponse = false;
                    Error("Ad loading timed out", true);
                    yield break;
                }
                yield return(null);
            }
        }
示例#2
0
 public XmlParser(string xml)
 {
     DeserializedXML = VUtils.Deserialize <VAST>(xml);
 }