static void SampleThreadedChunkUpload()
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");

            string             fname      = "DemoVideo.flv";
            FileStream         fileStream = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
            KalturaUploadToken myToken    = new KalturaUploadToken();

            myToken.FileName = fname;
            FileInfo f = new FileInfo(fname);

            myToken.FileSize = f.Length;

            string mediaName = "C# Media Entry Uploaded in chunks using threads";

            KalturaUploadToken uploadToken = client.UploadTokenService.Add(myToken);

            chunkThreaded(client.KS, fileStream, uploadToken.Id);

            KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();

            mediaResource.Token = uploadToken.Id;
            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = mediaName;
            mediaEntry.MediaType = KalturaMediaType.VIDEO;
            mediaEntry           = client.MediaService.Add(mediaEntry);
            mediaEntry           = client.MediaService.AddContent(mediaEntry.Id, mediaResource);
        }
Esempio n. 2
0
        /// <summary>
        /// Simple multi request example showing how to start session and list media in a single HTTP request
        /// </summary>
        static void MultiRequestExample()
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.StartMultiRequest();

            client.SessionService.Start(ADMIN_SECRET, "", KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");
            client.KS = "{1:result}"; // for the current multi request, the result of the first call will be used as the ks for next calls

            KalturaMediaEntryFilter filter = new KalturaMediaEntryFilter();

            filter.OrderBy = KalturaMediaEntryOrderBy.CREATED_AT_DESC;
            client.MediaService.List(filter, new KalturaFilterPager());

            KalturaMultiResponse response = client.DoMultiRequest();

            // in multi request, when there is an error, an exception is NOT thrown, so we should check manually
            if (response[1].GetType() == typeof(KalturaAPIException))
            {
                Console.WriteLine("Error listing media " + ((KalturaAPIException)response[1]).Message);

                // we can throw the exception if we want
                //throw (KalturaAPIException)response[1];
            }
            else
            {
                KalturaMediaListResponse mediaList = (KalturaMediaListResponse)response[1];
                Console.WriteLine("Total media entries: " + mediaList.TotalCount);
                foreach (KalturaMediaEntry mediaEntry in mediaList.Objects)
                {
                    Console.WriteLine("Media Name: " + mediaEntry.Name);
                }
            }
        }
Esempio n. 3
0
        //this function checks if a given flavor system name exist in the account.
        static int?CheckIfFlavorExist(String name)
        {
            KalturaClient client = new KalturaClient(GetConfig());
            string        ks     = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");

            client.KS = ks;

            //verify that the account we're testing has the new iPad flavor enabled on the default conversion profile
            KalturaConversionProfile defaultProfile = client.ConversionProfileService.GetDefault();
            KalturaConversionProfileAssetParamsFilter flavorsListFilter = new KalturaConversionProfileAssetParamsFilter();

            flavorsListFilter.SystemNameEqual          = name;
            flavorsListFilter.ConversionProfileIdEqual = defaultProfile.Id;

            KalturaConversionProfileAssetParamsListResponse list = client.ConversionProfileAssetParamsService.List(flavorsListFilter);

            if (list.TotalCount > 0)
            {
                return(list.Objects[0].AssetParamsId);
            }
            else
            {
                return(null);
            }
        }
        private static KalturaMetadata createMetadata(int metadataProfileId, KalturaMetadataObjectType objectType, string objectId, string xmlData)
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.USER, PARTNER_ID, 86400, "");

            return(client.MetadataService.Add(metadataProfileId, objectType, objectId, xmlData));
        }
Esempio n. 5
0
        static void SampleMetadataOperations()
        {
            // The Schema file for the field
            // Currently, you must build the xsd yourself. There is no utility provided.
            string       xsdFile    = "MetadataSchema.xsd";
            StreamReader fileStream = File.OpenText(xsdFile);
            string       xsd        = fileStream.ReadToEnd();

            string fieldValue = "VobSub";
            string xmlData    = "<metadata><SubtitleFormat>" + fieldValue + "</SubtitleFormat></metadata>";

            KalturaClient client = new KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID);

            // Setup a pager and search to use
            KalturaMediaEntryFilter mediaEntryFilter = new KalturaMediaEntryFilter();

            mediaEntryFilter.OrderBy        = KalturaMediaEntryOrderBy.CREATED_AT_ASC;
            mediaEntryFilter.MediaTypeEqual = KalturaMediaType.VIDEO;

            KalturaFilterPager pager = new KalturaFilterPager();

            pager.PageSize  = 1;
            pager.PageIndex = 1;

            KalturaMetadataProfile newMetadataProfile = new KalturaMetadataProfile();

            newMetadataProfile.MetadataObjectType = KalturaMetadataObjectType.ENTRY;
            newMetadataProfile.Name = "Test";

            Console.WriteLine("List videos, get the first one...");
            IList <KalturaMediaEntry> entries = client.MediaService.List(mediaEntryFilter, pager).Objects;
            KalturaMediaEntry         entry   = entries[0];

            KalturaMetadataProfile metadataProfile = client.MetadataProfileService.Add(newMetadataProfile, xsd);

            Console.WriteLine("1. Successfully created the custom metadata profile " + metadataProfile.Name + ".");

            KalturaMetadata metadata = client.MetadataService.Add(metadataProfile.Id, metadataProfile.MetadataObjectType, entry.Id, xmlData);

            Console.WriteLine("2. Successfully added the custom data field for entryid: " + entry.Id);

            KalturaMetadataFilter metadataFilter = new KalturaMetadataFilter();

            metadataFilter.ObjectIdEqual          = entry.Id;
            metadataFilter.MetadataProfileIdEqual = metadataProfile.Id;
            IList <KalturaMetadata> metadataList = client.MetadataService.List(metadataFilter).Objects;

            if (metadataList.Count == 0)
            {
                throw new Exception("Failed to find metadata for entryid: " + entry.Id);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Shows how to start session and upload media from a local file server
        /// </summary>
        /// <param name="fileStream"></param>
        /// <param name="mediaType"></param>
        /// <param name="name"></param>
        public static KalturaBulkUpload StartSessionBulkUploadAddMedia(FileStream fileStream, KalturaMediaType mediaType, string name)
        {
            var client = new Kaltura.KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            var ks = client.SessionService.Start(KalturaConfigManager.Kulturasecret, KalturaConfigManager.Kulturauserid, KalturaSessionType.USER, KalturaConfigManager.Kulturapartnerid, 86400, "");

            client.KS = ks;
            //return mediaEntry;
            return(null);
        }
Esempio n. 7
0
        /// <summary>
        /// Shows how to start session, create a mix, add media, and append it to a mix timeline using multi request
        /// </summary>
        private static void AdvancedMultiRequestExample()
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.StartMultiRequest();

            // Request 1
            client.SessionService.Start(ADMIN_SECRET, "", KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");
            client.KS = "{1:result}"; // for the current multi request, the result of the first call will be used as the ks for next calls

            FileStream fileStream = new FileStream("DemoVideo.flv", FileMode.Open, FileAccess.Read);

            // Request 2
            KalturaUploadToken uploadToken = client.UploadTokenService.Add();

            // Request 3
            uploadToken = client.UploadTokenService.Upload("{2:result}", fileStream);

            // Request 4
            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using C#.Net Client To Test Flavor Replace";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;
            mediaEntry           = client.MediaService.Add(mediaEntry);

            // Request 5
            KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();

            mediaResource.Token = "{2:result:id}";
            mediaEntry          = client.MediaService.AddContent("{4:result}", mediaResource);

            // map paramters from responses to requests according to response calling order and names to request calling order and C# method parameter name
            client.MapMultiRequestParam(2, ":id", 3, "uploadTokenId");
            client.MapMultiRequestParam(4, ":id", 5, "entryId");

            KalturaMultiResponse response = client.DoMultiRequest();

            foreach (object obj in response)
            {
                if (obj.GetType() == typeof(KalturaAPIException))
                {
                    Console.WriteLine("Error occurred: " + ((KalturaAPIException)obj).Message);
                }
            }

            // when accessing the response object we will use an index and not the response number (response number - 1)
            if (response[4].GetType() == typeof(KalturaMediaEntry))
            {
                KalturaMediaEntry newMediaEntry = (KalturaMediaEntry)response[4];
                Console.WriteLine("Multirequest newly added entry id: " + newMediaEntry.Id);
            }
        }
Esempio n. 8
0
        private static KalturaMetadataProfile createMetadataProfile(KalturaMetadataObjectType objectType, string xsdData)
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");

            KalturaMetadataProfile metadataProfile = new KalturaMetadataProfile();

            metadataProfile.MetadataObjectType = objectType;
            metadataProfile.Name = "test_" + Guid.NewGuid().ToString();

            return(client.MetadataProfileService.Add(metadataProfile, xsdData));
        }
Esempio n. 9
0
        private static KalturaMediaEntry createEntry()
        {
            KalturaClient client = new KalturaClient(GetConfig());

            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.USER, PARTNER_ID, 86400, "");

            KalturaMediaEntry entry = new KalturaMediaEntry();

            entry.MediaType = KalturaMediaType.VIDEO;
            entry.Name      = "test_" + Guid.NewGuid().ToString();
            entry.Tags      = uniqueTag;

            return(client.MediaService.Add(entry));
        }
Esempio n. 10
0
        // this method is deprecated and should be avoided.
        // see above SampleReplaceVideoFlavorAndAddCaption for the current method of uploading media.
        // new method should use the Add method along with specific appropriate Resource object.
        static void StartSessionAndUploadMedia(Uri url)
        {
            KalturaClient client = new KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.USER, PARTNER_ID, 86400, "");

            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using .Net Client";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;

            // add the media using the upload token
            mediaEntry = client.MediaService.AddFromUrl(mediaEntry, url.ToString());

            Console.WriteLine("New media was created with the following id: " + mediaEntry.Id);
        }
Esempio n. 11
0
        /// <summary>
        /// Shows how to start session and upload media from a web accessible server
        /// </summary>
        public static void StartSessionAndUploadMedia(Uri url)
        {
            var client = new Kaltura.KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            var ks = client.SessionService.Start(KalturaConfigManager.Kulturasecret, KalturaConfigManager.Kulturauserid, KalturaSessionType.USER, KalturaConfigManager.Kulturapartnerid, 86400, "");

            client.KS = ks;

            var mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using .Net Client";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;

            // add the media using the upload token
            mediaEntry = client.MediaService.AddFromUrl(mediaEntry, url.ToString());

            Console.WriteLine("New media was created with the following id: " + mediaEntry.Id);
        }
Esempio n. 12
0
        /// <summary>
        /// Shows how to start session and upload media from a local file server
        /// </summary>
        /// <param name="fileStream"></param>
        /// <param name="mediaType"></param>
        /// <param name="name"></param>
        public static KalturaMediaEntry StartSessionAndUploadMedia(FileStream fileStream, KalturaMediaType mediaType, string name)
        {
            var client = new Kaltura.KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            var ks = client.SessionService.Start(KalturaConfigManager.Kulturasecret, KalturaConfigManager.Kulturauserid, KalturaSessionType.USER, KalturaConfigManager.Kulturapartnerid, 86400, "");

            client.KS = ks;

            // upload the media
            var uploadTokenId = client.MediaService.Upload(fileStream); // synchronous proccess
            var mediaEntry    = new KalturaMediaEntry();

            mediaEntry.Name      = name;
            mediaEntry.MediaType = mediaType;
            // add the media using the upload token
            mediaEntry = client.MediaService.AddFromUploadedFile(mediaEntry, uploadTokenId);

            return(mediaEntry);
        }
Esempio n. 13
0
        // this method is deprecated and should be avoided.
        // see above SampleReplaceVideoFlavorAndAddCaption for the current method of uploading media.
        // new method should use the Add method along with specific appropriate Resource object and Upload Token.
        static KalturaMediaEntry StartSessionAndUploadMedia(FileStream fileStream)
        {
            KalturaClient client = new KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.USER, PARTNER_ID, 86400, "");

            // upload the media
            string            uploadTokenId = client.MediaService.Upload(fileStream); // synchronous proccess
            KalturaMediaEntry mediaEntry    = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using .Net Client";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;

            // add the media using the upload token
            mediaEntry = client.MediaService.AddFromUploadedFile(mediaEntry, uploadTokenId);

            Console.WriteLine("New media was created with the following id: " + mediaEntry.Id);

            return(mediaEntry);
        }
        public void upload()
        {
            KalturaClient client = new KalturaClient(KalturaClientTester.GetConfig());

            client.KS = ks;

            if (ranges.Count.Equals(0))
            {
                // no more items - avoid null pointer exception
                KalturaClientTester.workingThreads--;
                return;
            }
            byte[] chunk = new byte[this.chunkSize];
            int    index = ranges.Last.Value;

            // mark as uploaded
            ranges.RemoveLast();
            // read part of file
            file.Seek(index, SeekOrigin.Begin);
            int  bytesRead = file.Read(chunk, 0, this.chunkSize);
            long resumeAt  = index;

            try
            {
                Stream chunkFile = new MemoryStream(chunk);
                client.UploadTokenService.Upload(uploadTokenId, chunkFile, true, false, resumeAt);
                chunkFile.Close();
            }
            catch (KalturaAPIException ex)
            {
                Console.WriteLine("failed to upload and resume at position " + resumeAt + " message: [" + ex.Message + "] replacing last index " + index);
                // put chunk start position back in the queue so will be picked by next thread
                ranges.AddLast(index);
            }
            finally
            {
                KalturaClientTester.workingThreads--;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Shows how to start session, create a mix, add media, and append it to a mix timeline using multi request
        /// </summary>
        private static void AdvancedMultiRequestExample()
        {
            FileStream fileStream = new FileStream("DemoVideo.flv", FileMode.Open, FileAccess.Read);

            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using C#.Net Client To Test Flavor Replace";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;

            KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();

            mediaResource.Token = "{1:result:id}";

            KalturaClient client = new KalturaClient(GetConfig());

            client.KS = client.GenerateSession(ADMIN_SECRET, "", KalturaSessionType.ADMIN, PARTNER_ID);
            client.StartMultiRequest();
            client.UploadTokenService.Add();
            client.MediaService.Add(mediaEntry);
            client.UploadTokenService.Upload("{1:result:id}", fileStream);
            client.MediaService.AddContent("{2:result:id}", mediaResource);

            KalturaMultiResponse response = client.DoMultiRequest();

            foreach (object obj in response)
            {
                if (obj is KalturaAPIException)
                {
                    Console.WriteLine("Error occurred: " + ((KalturaAPIException)obj).Message);
                }
            }

            // when accessing the response object we will use an index and not the response number (response number - 1)
            if (response[3] is KalturaMediaEntry)
            {
                KalturaMediaEntry newMediaEntry = (KalturaMediaEntry)response[3];
                Console.WriteLine("Multirequest newly added entry id: " + newMediaEntry.Id + ", status: " + newMediaEntry.Status);
            }
        }
Esempio n. 16
0
 public KalturaBulkUploadService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 17
0
        static void SampleMetadataOperations()
        {
            // The metadata field we'll add/update
            string metaDataFieldName = "SubtitleFormat";
            string fieldValue        = "VobSub";

            // The Schema file for the field
            // Currently, you must build the xsd yourself. There is no utility provided.
            string xsdFile = "MetadataSchema.xsd";

            KalturaClient client = new KalturaClient(GetConfig());

            // start new session (client session is enough when we do operations in a users scope)
            string ks = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");

            client.KS = ks;

            // Setup a pager and search to use
            KalturaFilterPager      pager  = new KalturaFilterPager();
            KalturaMediaEntryFilter search = new KalturaMediaEntryFilter();

            search.OrderBy        = KalturaMediaEntryOrderBy.CREATED_AT_ASC;
            search.MediaTypeEqual = KalturaMediaType.VIDEO;  // Video only
            pager.PageSize        = 10;
            pager.PageIndex       = 1;

            Console.WriteLine("List videos, get the first one...");

            // Get 10 video entries, but we'll just use the first one returned
            IList <KalturaMediaEntry> entries = client.MediaService.List(search, pager).Objects;
            // Check if there are any custom fields defined in the KMC (Settings -> Custom Data)
            // for the first item returned by the previous listaction
            KalturaMetadataProfileFilter   filter   = new KalturaMetadataProfileFilter();
            IList <KalturaMetadataProfile> metadata = client.MetadataProfileService.List(filter, pager).Objects;
            int    profileId = 0;
            string name      = "";
            string id        = "";

            if (metadata.Count > 0)
            {
                profileId = metadata[0].Id;
                name      = entries[0].Name;
                id        = entries[0].Id;
                Console.WriteLine("1. There are custom fields for video: " + name + ", entryid: " + id);
            }
            else
            {
                Console.WriteLine("1. This publisher account doesn't have any custom metadata profiles enabled.");
                Console.WriteLine("Exiting the metadata test (enable customer metadata in Admin Console and create a profile in KMC first).");
                return;
            }

            // Add a custom data entry in the KMC  (Settings -> Custom Data)
            KalturaMetadataProfile profile = new KalturaMetadataProfile();

            profile.MetadataObjectType = KalturaMetadataObjectType.ENTRY;
            profile.Name = metadata[0].Name;
            string viewsData = "";

            StreamReader           fileStream     = File.OpenText(xsdFile);
            string                 xsd            = fileStream.ReadToEnd();
            KalturaMetadataProfile metadataResult = client.MetadataProfileService.Update(profileId, profile, xsd, viewsData);

            if (metadataResult.Xsd != null)
            {
                Console.WriteLine("2. Successfully created the custom data field " + metaDataFieldName + ".");
            }
            else
            {
                Console.WriteLine("2. Failed to create the custom data field.");
            }

            // Add the custom metadata value to the first video
            KalturaMetadataFilter filter2 = new KalturaMetadataFilter();

            filter2.ObjectIdEqual = entries[0].Id;
            string          xmlData   = "<metadata><SubtitleFormat>" + fieldValue + "</SubtitleFormat></metadata>";
            KalturaMetadata metadata2 = client.MetadataService.Add(profileId, profile.MetadataObjectType, entries[0].Id, xmlData);

            if (metadata2.Xml != null)
            {
                Console.WriteLine("3. Successfully added the custom data field for video: " + name + ", entryid: " + id);
                string xmlStr = metadata2.Xml;
                Console.WriteLine("XML used: " + xmlStr);
            }
            else
            {
                Console.WriteLine("3. Failed to add the custom data field.");
            }

            // Now lets change the value (update) of the custom field
            // Get the metadata for the video
            KalturaMetadataFilter filter3 = new KalturaMetadataFilter();

            filter3.ObjectIdEqual = entries[0].Id;
            IList <KalturaMetadata> metadataList = client.MetadataService.List(filter3).Objects;

            if (metadataList[0].Xml != null)
            {
                Console.WriteLine("4. Current metadata for video: " + name + ", entryid: " + id);
                string xmlquoted = metadataList[0].Xml;
                Console.WriteLine("XML: " + xmlquoted);
                string xml = metadataList[0].Xml;
                // Make sure we find the old value in the current metadata
                int pos = xml.IndexOf("<" + metaDataFieldName + ">" + fieldValue + "</" + metaDataFieldName + ">");
                if (pos == -1)
                {
                    Console.WriteLine("4. Failed to find metadata STRING for video: " + name + ", entryid: " + id);
                }
                else
                {
                    System.Text.RegularExpressions.Regex pattern = new System.Text.RegularExpressions.Regex("@<" + metaDataFieldName + ">(.+)</" + metaDataFieldName + ">@");
                    xml = pattern.Replace(xml, "<" + metaDataFieldName + ">Ogg Writ</" + metaDataFieldName + ">");
                    KalturaMetadata rc = client.MetadataService.Update(metadataList[0].Id, xml);
                    Console.WriteLine("5. Updated metadata for video: " + name + ", entryid: " + id);
                    xmlquoted = rc.Xml;
                    Console.WriteLine("XML: " + xmlquoted);
                }
            }
            else
            {
                Console.WriteLine("4. Failed to find metadata for video: " + name + ", entryid: " + id);
            }
        }
Esempio n. 18
0
        // This will guide you through uploading a video, getting a specific transcoding flavor, replacing a flavor, and uploading a caption file.
        static void SampleReplaceVideoFlavorAndAddCaption()
        {
            // Upload a file
            Console.WriteLine("1. Upload a video file");
            FileStream    fileStream = new FileStream("DemoVideo.flv", FileMode.Open, FileAccess.Read);
            KalturaClient client     = new KalturaClient(GetConfig());
            string        ks         = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");

            client.KS = ks;
            KalturaUploadToken uploadToken = client.UploadTokenService.Add();

            client.UploadTokenService.Upload(uploadToken.Id, fileStream);
            KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();

            mediaResource.Token = uploadToken.Id;
            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();

            mediaEntry.Name      = "Media Entry Using C#.Net Client To Test Flavor Replace";
            mediaEntry.MediaType = KalturaMediaType.VIDEO;
            mediaEntry           = client.MediaService.Add(mediaEntry);
            mediaEntry           = client.MediaService.AddContent(mediaEntry.Id, mediaResource);

            //verify that the account we're testing has the iPad flavor enabled
            int?flavorId = CheckIfFlavorExist("iPad");

            if (flavorId == null)
            {
                Console.WriteLine("!! Default conversion profile does NOT include the new iPad flavor");
                Console.WriteLine("!! Skipping the iPad flavor replace test, make sure account has newiPad flavor enabled.");
            }
            else
            {
                int iPadFlavorId = (int)flavorId; //C# failsafe from nullable int - we cast it to int
                Console.WriteLine("** Default conversion profile includes the new iPad flavor, id is: " + iPadFlavorId);

                //Detect the conversion readiness status of the iPad flavor and download the file when ready -
                Boolean            statusB    = false;
                KalturaFlavorAsset iPadFlavor = null;
                while (statusB == false)
                {
                    Console.WriteLine("2. Waiting for the iPad flavor to be available...");
                    System.Threading.Thread.Sleep(5000);
                    KalturaFlavorAssetFilter flavorAssetsFilter = new KalturaFlavorAssetFilter();
                    flavorAssetsFilter.EntryIdEqual = mediaEntry.Id;
                    KalturaFlavorAssetListResponse flavorAssets = client.FlavorAssetService.List(flavorAssetsFilter);
                    foreach (KalturaFlavorAsset flavor in flavorAssets.Objects)
                    {
                        if (flavor.FlavorParamsId == iPadFlavorId)
                        {
                            iPadFlavor = flavor;
                            statusB    = flavor.Status == KalturaFlavorAssetStatus.READY;
                            if (flavor.Status == KalturaFlavorAssetStatus.NOT_APPLICABLE)
                            {
                                //in case the Kaltura Transcoding Decision Layer decided not to convert to this flavor, let's force it.
                                client.FlavorAssetService.Convert(mediaEntry.Id, iPadFlavor.FlavorParamsId);
                            }
                            Console.WriteLine("3. iPad flavor (" + iPadFlavor.FlavorParamsId + "). It's " + (statusB ? "Ready to ROCK!" : "being converted. Waiting..."));
                        }
                    }
                }

                //this is the download URL for the actual Video file of the iPad flavor
                string iPadFlavorUrl = client.FlavorAssetService.GetDownloadUrl(iPadFlavor.Id);
                Console.WriteLine("4. iPad Flavor URL is: " + iPadFlavorUrl);

                //Alternatively, download URL for a given flavor id can also be retrived by creating the playManifest URL -
                string playManifestURL = "http://www.kaltura.com/p/{partnerId}/sp/0/playManifest/entryId/{entryId}/format/url/flavorParamId/{flavorParamId}/ks/{ks}/{fileName}.mp4";
                playManifestURL = playManifestURL.Replace("{partnerId}", PARTNER_ID.ToString());
                playManifestURL = playManifestURL.Replace("{entryId}", mediaEntry.Id);
                playManifestURL = playManifestURL.Replace("{flavorParamId}", iPadFlavor.FlavorParamsId.ToString());
                playManifestURL = playManifestURL.Replace("{ks}", client.KS);
                playManifestURL = playManifestURL.Replace("{fileName}", mediaEntry.Name);
                Console.WriteLine("4. iPad Flavor playManifest URL is: " + playManifestURL);

                //now let's replace the flavor with our video file (e.g. after processing the file outside of Kaltura)
                FileStream fileStreamiPad = new FileStream("DemoVideoiPad.mp4", FileMode.Open, FileAccess.Read);
                uploadToken = client.UploadTokenService.Add();
                client.UploadTokenService.Upload(uploadToken.Id, fileStreamiPad);
                mediaResource       = new KalturaUploadedFileTokenResource();
                mediaResource.Token = uploadToken.Id;
                KalturaFlavorAsset newiPadFlavor = client.FlavorAssetService.SetContent(iPadFlavor.Id, mediaResource);
                Console.WriteLine("5. iPad Flavor was replaced! id: " + newiPadFlavor.Id);
            }

            //now let's upload a new caption file to this entry
            FileStream fileStreamCaption = new FileStream("DemoCaptions.srt", FileMode.Open, FileAccess.Read);

            uploadToken = client.UploadTokenService.Add();
            client.UploadTokenService.Upload(uploadToken.Id, fileStreamCaption);
            KalturaCaptionAsset captionAsset = new KalturaCaptionAsset();

            captionAsset.Label    = "Test C# Uploaded Caption";
            captionAsset.Language = KalturaLanguage.EN;
            captionAsset.Format   = KalturaCaptionType.SRT;
            captionAsset.FileExt  = "srt";
            captionAsset          = client.CaptionAssetService.Add(mediaEntry.Id, captionAsset);
            Console.WriteLine("6. Added a new caption asset. Id: " + captionAsset.Id);
            KalturaUploadedFileTokenResource captionResource = new KalturaUploadedFileTokenResource();

            captionResource.Token = uploadToken.Id;
            captionAsset          = client.CaptionAssetService.SetContent(captionAsset.Id, captionResource);
            Console.WriteLine("7. Uploaded a new caption file and attached to caption asset id: " + captionAsset.Id);
            string captionUrl = client.CaptionAssetService.GetUrl(captionAsset.Id);

            Console.WriteLine("7. Newly created Caption Asset URL is: " + captionUrl);
        }
Esempio n. 19
0
 public KalturaCuePointService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 20
0
 public KalturaMixingService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 21
0
 public KalturaShortLinkService(KalturaClient client)
     : base(client)
 {
 }
 public KalturaGenericDistributionProviderActionService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 23
0
 public KalturaCaptionParamsService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 24
0
 public KalturaDataService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 25
0
 public KalturaMediaService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 26
0
 public KalturaUiConfService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 27
0
 public KalturaStatsService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 28
0
 public KalturaSearchService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 29
0
 public KalturaUploadTokenService(KalturaClient client)
     : base(client)
 {
 }
Esempio n. 30
0
 public KalturaDocumentsService(KalturaClient client)
     : base(client)
 {
 }