static async Task AuthenticateAsync()
        {
            // Get an access token with allow edit permissions
            var allowEditClient = new VideoIndexerClient(Location, AccountId, ApiKey, true);
            var allowEditToken  = await allowEditClient.GetAccountAccessTokenAsync();

            Console.WriteLine($"Allow edit account token: { allowEditToken }");
            Console.WriteLine();

            // Get a second access token with allow edit permissions
            var allowEditToken2 = await allowEditClient.GetAccountAccessTokenAsync();

            Console.WriteLine($"Allow edit account token: { allowEditToken }");
            Console.WriteLine();

            // Get an access token with read only permissions
            var readOnlyClient = new VideoIndexerClient(Location, AccountId, ApiKey, false);
            var readOnlyToken  = await readOnlyClient.GetAccountAccessTokenAsync();

            Console.WriteLine($"Read only account token: { readOnlyToken }");
            Console.WriteLine();

            // Get a video access token
            var readOnlyVideoAccessToken = await readOnlyClient.GetReadOnlyVideoAccessTokenAsync("0aef5bda16");

            Console.WriteLine($"Read only video access token: { allowEditToken }");
            Console.WriteLine();
        }
        static async Task ListAccountsAsync()
        {
            var client       = new VideoIndexerClient(Location, AccountId, ApiKey, false);
            var accountsJson = await client.GetAccounts();

            Console.WriteLine(accountsJson);
        }
        static async Task UpdateVideoTranscript(string videoId, string file)
        {
            var client = new VideoIndexerClient(Location, AccountId, ApiKey, true);

            string transcript = File.ReadAllText(file);

            await client.UpdateVideoTranscript(videoId, transcript);
        }
        static async Task <string> GetVideoPlayerWidgetAsync(string videoId)
        {
            var readOnlyClient = new VideoIndexerClient(Location, AccountId, ApiKey, false);

            string url = await readOnlyClient.GetVideoPlayerWidgetAsync(videoId);

            return(url);
        }
Exemplo n.º 5
0
        public async Task SetActiveVideoAsync(Result video)
        {
            SelectedVideo = video;
            var widgets = await VideoIndexerClient.GetWidgetAsync(video.Id);

            PlayerWidgetUri   = widgets.player;
            InsightsWidgetUri = widgets.insights;
        }
        static async Task DownloadVideoCaptions(string videoId, string file, string language)
        {
            var readOnlyClient = new VideoIndexerClient(Location, AccountId, ApiKey, false);

            var captions = await readOnlyClient.GetVideoCaptions(videoId, "Vtt", language);

            File.WriteAllText(file, captions);

            Console.WriteLine(captions);
        }
        static async Task ListVideosAsync()
        {
            var client      = new VideoIndexerClient(Location, AccountId, ApiKey, false);
            var mediaAssets = await client.ListVideosAsync();

            foreach (var mediaAsset in mediaAssets.results)
            {
                Console.WriteLine($"{ mediaAsset.name } - { mediaAsset.durationInSeconds } - { mediaAsset.userName }");
            }
        }
        static async Task IndexMediaBatch(string containerName, List <Tuple <string, string> > mediaItems)
        {
            var container = new MediaAssetsContainer(StorageAccountConnectionString, containerName);
            var client    = new VideoIndexerClient(Location, AccountId, ApiKey, true);

            foreach (var mediaItem in mediaItems)
            {
                Console.WriteLine($"Indexing: { mediaItem }");
                string sasUrl = container.GetBlobReadSas(mediaItem.Item1);
                string result = await client.IndexAsync(sasUrl, mediaItem.Item2);

                Console.WriteLine(result);
                Thread.Sleep(15000);
            }
        }
Exemplo n.º 9
0
        public async Task ReloadVideosAsync()
        {
            _videos.Clear();
            GetVideosResult videos;

            do
            {
                videos = await VideoIndexerClient.GetVideosAsync();

                foreach (var video in videos.Results)
                {
                    _videos.Add(video);
                }
            } while (videos.NextPage != null && !videos.NextPage.Done);
        }
        static async Task SearchFaceAsync(string name)
        {
            // Create a read-only client
            var readOnlyClient = new VideoIndexerClient(Location, AccountId, ApiKey, false);

            // Retrieve the search results
            var searcResults = await readOnlyClient.SearchFaceAsync(name);

            // Display the search results
            foreach (var result in searcResults.results)
            {
                Console.WriteLine($"{ result.name }");
                foreach (var match in result.searchMatches)
                {
                    Console.WriteLine($"\t{ match.startTime.ToString(@"hh\:mm\:ss") } - { match.type } - { match.text }");
                }
                Console.WriteLine();
            }
        }
        static async Task UploadAndIndexMediaAsync(string containerName, string path, string blobName, string videoName)
        {
            var container = new MediaAssetsContainer(StorageAccountConnectionString, containerName);

            Console.WriteLine($"Uploading { blobName } to blob storage...");
            await container.UploadFileAsync(path, blobName);

            Console.WriteLine("Creating SAS...");
            string sasUrl = container.GetBlobReadSas(blobName);

            var client = new VideoIndexerClient(Location, AccountId, ApiKey, true);

            Console.WriteLine("Calling API...");
            var response = await client.IndexAsync(sasUrl, videoName);

            Console.WriteLine();
            Console.WriteLine(response);
            Console.WriteLine();
        }
        static async Task GetIndex(string mediaAssetId)
        {
            var client = new VideoIndexerClient(Location, AccountId, ApiKey, false);

            await client.GetIndexAsync(mediaAssetId);
        }
        static async Task UpdateVideoFaceAsync(string videoId, int faceId, string newName)
        {
            var client = new VideoIndexerClient(Location, AccountId, ApiKey, true);

            await client.UpdateVideoFaceAsync(videoId, faceId, newName);
        }
        static async Task GetTranslatedIndex()
        {
            var client = new VideoIndexerClient(Location, AccountId, ApiKey, false);

            await client.GetIndexAsync(MediaAssetId, "sv-SE");
        }
Exemplo n.º 15
0
        public async Task <string> UploadVideoAsync(string name, Stream video)
        {
            var uri = await StorageRepository.UploadVideoAsync(name, video);

            return(await VideoIndexerClient.UploadVideoToVideoIndexerAsync(uri));
        }