Пример #1
0
        private static Uri GetStreamingUri(this IAsset asset, string streamingParameter)
        {
            if (asset == null)
            {
                throw new ArgumentNullException("asset", "The asset cannot be null.");
            }

            Uri        smoothStreamingUri = null;
            IAssetFile manifestAssetFile  = asset.GetManifestAssetFile();

            if (manifestAssetFile != null)
            {
                ILocator originLocator = asset
                                         .Locators
                                         .ToList()
                                         .Where(l => l.Type == LocatorType.OnDemandOrigin)
                                         .OrderBy(l => l.ExpirationDateTime)
                                         .FirstOrDefault();
                if (originLocator != null)
                {
                    smoothStreamingUri = new Uri(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            ILocatorExtensions.BaseStreamingUrlTemplate,
                            originLocator.Path.TrimEnd('/'),
                            manifestAssetFile.Name,
                            streamingParameter),
                        UriKind.Absolute);
                }
            }

            return(smoothStreamingUri);
        }
        private static Uri GetStreamingUri(this ILocator originLocator, string streamingParameter)
        {
            if (originLocator == null)
            {
                throw new ArgumentNullException("locator", "The locator cannot be null.");
            }

            if (originLocator.Type != LocatorType.OnDemandOrigin)
            {
                throw new ArgumentException("The locator type must be on-demand origin.", "originLocator");
            }

            Uri        smoothStreamingUri = null;
            IAsset     asset             = originLocator.Asset;
            IAssetFile manifestAssetFile = asset.GetManifestAssetFile();

            if (manifestAssetFile != null)
            {
                smoothStreamingUri = new Uri(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        BaseStreamingUrlTemplate,
                        originLocator.Path.TrimEnd('/'),
                        manifestAssetFile.Name,
                        streamingParameter),
                    UriKind.Absolute);
            }

            return(smoothStreamingUri);
        }
Пример #3
0
        public void ShouldThrowGetManifestAssetFileIfAssetIsNull()
        {
            IAsset nullAsset = null;

            nullAsset.GetManifestAssetFile();
        }