/// <summary>
        /// Creates a new audio track in Brightcove by uploading a file.
        /// </summary>
        /// <param name="audioTrack">The audio track to create</param>
        /// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
        /// <returns>The numeric ID of the uploaded track</returns>
        public long CreateAudioTrack(BrightcoveAudioTrack audioTrack, FileUploadInfo fileUploadInfo)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("create_audiotrack",
                                                                         methodParams => methodParams.Add("audiotrack", audioTrack));

            return(RunFilePost <BrightcoveResultContainer <long> >(parms, fileUploadInfo).Result);
        }
        /// <summary>
        /// Gets the audiotrack upload status.
        /// </summary>
        /// <param name="referenceId">The reference id.</param>
        /// <returns>The status of the upload</returns>
        public BrightcoveUploadStatus GetAudioTrackUploadStatus(string referenceId)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("get_audiotrack_upload_status",
                                                                         methodParams => methodParams.Add("reference_id", referenceId));

            return(RunPost <BrightcoveResultContainer <BrightcoveUploadStatus> >(parms).Result);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a playlist.
        /// </summary>
        /// <param name="playlist">The playlist you'd like to create.</param>
        /// <returns>The ID of the newly created playlist.</returns>
        public long CreateAudioTrackPlaylist(BrightcoveAudioTrackPlaylist playlist)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("create_audiotrack_playlist",
                                                                         methodParams => methodParams.Add("audiotrack_playlist", playlist));

            return(RunPost <BrightcoveResultContainer <long> >(parms).Result);
        }
Beispiel #4
0
        /// <summary>
        /// Updates the specified video.
        /// </summary>
        /// <param name="video"></param>
        /// <returns></returns>
        public BrightcoveVideo UpdateVideo(BrightcoveVideo video)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("update_video",
                                                                         methodParams => methodParams.Add("video", video));

            return(RunPost <BrightcoveResultContainer <BrightcoveVideo> >(parms).Result);
        }
Beispiel #5
0
        /// <summary>
        /// Updates a playlist, specified by playlist ID or reference ID. Either a playlist ID or a reference ID must be
        /// supplied. If you are updating the value of the reference ID, then both the playlist ID and reference ID must be supplied.
        /// </summary>
        /// <param name="playlist">The playlist you'd like to update.</param>
        /// <returns>The playlist that was updated</returns>
        public BrightcovePlaylist UpdatePlaylist(BrightcovePlaylist playlist)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("update_playlist",
                                                                         methodParams => methodParams.Add("playlist", playlist));

            return(RunPost <BrightcoveResultContainer <BrightcovePlaylist> >(parms).Result);
        }
        /// <summary>
        /// Updates the audio track information for a Brightcove audio track.
        /// </summary>
        /// <param name="audioTrack"></param>
        /// <returns>The updated BrightcoveAudioTrack</returns>
        public BrightcoveAudioTrack UpdateAudioTrack(BrightcoveAudioTrack audioTrack)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("update_audiotrack",
                                                                         methodParams => methodParams.Add("audiotrack", audioTrack));

            return(RunPost <BrightcoveResultContainer <BrightcoveAudioTrack> >(parms).Result);
        }
Beispiel #7
0
        /// <summary>
        /// Builds a collection of write params common to all API write requests.
        /// </summary>
        /// <param name="method">The Brightcove write method to perform.</param>
        /// <param name="addMethodParamsCallback">The callback to performed on the passed dictionary.</param>
        /// <returns>A <see cref="NameValueCollection"/> containing the basic POST parameters.</returns>
        private BrightcoveParamCollection CreateWriteParamCollection(string method, Action <IDictionary <string, object> > addMethodParamsCallback)
        {
            BrightcoveParamCollection parms = BuildBasicWriteParams(method);

            if (addMethodParamsCallback != null)
            {
                BrightcoveParamCollection methodParams = (BrightcoveParamCollection)parms[_methodParamsKey];
                addMethodParamsCallback(methodParams);
            }
            return(parms);
        }
Beispiel #8
0
        /// <summary>
        /// Deletes the specified previously shared video from a list of sharee accounts. If a shared version of the specified video does not exist in a sharee account, no action is taken.
        /// </summary>
        /// <param name="videoId">The id for the video that is shared.</param>
        /// <param name="shareeAccountIds">List of Account IDs from which to stop sharing the video.</param>
        /// <returns>A collection of sharee account IDs for accounts previously containing shared videos specifically removed by this method.</returns>
        public ICollection <long> UnshareVideo(long videoId, IEnumerable <long> shareeAccountIds)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("unshare_video",
                                                                         methodParams =>
            {
                methodParams.Add("video_id", videoId);
                methodParams.Add("sharee_account_ids", shareeAccountIds);
            });

            return(RunPost <BrightcoveResultContainer <long[]> >(parms).Result);
        }
Beispiel #9
0
        private void DoRemoveLogoOverlay(long videoId, string videoReferenceId)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(videoId, videoReferenceId, "video_id", "video_reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("remove_logo_overlay",
                                                                         methodParams => methodParams.Add(propName, propValue));

            RunPost <BrightcoveResultContainer <long> >(parms);
        }
Beispiel #10
0
        /// <summary>
        /// Determines the status of an upload.
        /// </summary>
        /// <param name="videoId">The ID of the video whose status you'd like to get.</param>
        /// <param name="referenceId">The reference ID of the video whose status you'd like to get.</param>
        /// <returns>A <see cref="BrightcoveUploadStatus"/> that specifies the current state of the upload.</returns>
        private BrightcoveUploadStatus DoGetUploadStatus(long videoId, string referenceId)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(videoId, referenceId, "video_id", "reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("get_upload_status",
                                                                         methodParams => methodParams.Add(propName, propValue));

            return(RunPost <BrightcoveResultContainer <BrightcoveUploadStatus> >(parms).Result);
        }
Beispiel #11
0
        /// <summary>
        /// Shares the specified video with a list of sharee accounts.
        /// </summary>
        /// <param name="videoId">The id for video that will be shared.</param>
        /// <param name="autoAccept">If the target account has the option enabled, setting this flag to true will bypass
        /// the approval process, causing the shared video to automatically appear in the target account's library. If the
        /// target account does not have the option enabled, or this flag is unspecified or false, then the shared video
        /// will be queued up to be approved by the target account before appearing in their library.</param>
        /// <param name="forceReshare">If true, indicates that if the shared video already exists in the target account's
        /// library, it should be overwritten by the video in the sharer's account.</param>
        /// <param name="shareeAccountIds">List of Account IDs to share video with.</param>
        /// <returns>List of new video IDs (one for each account ID).</returns>
        public ICollection <long> ShareVideo(long videoId, bool autoAccept, bool forceReshare, IEnumerable <long> shareeAccountIds)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("share_video",
                                                                         methodParams =>
            {
                methodParams.Add("video_id", videoId);
                methodParams.Add("auto_accept", autoAccept.ToString().ToLower());
                methodParams.Add("force_reshare", forceReshare.ToString().ToLower());
                methodParams.Add("sharee_account_ids", shareeAccountIds);
            });

            return(RunPost <BrightcoveResultContainer <long[]> >(parms).Result);
        }
Beispiel #12
0
        /// <summary>
        /// Builds a basic collection of write params common to all API write requests.
        /// </summary>
        /// <param name="method">The name of a particular Brightcove write API method.</param>
        /// <returns>A <see cref="NameValueCollection"/> containing the basic POST parameters.</returns>
        private BrightcoveParamCollection BuildBasicWriteParams(string method)
        {
            BrightcoveParamCollection methodParams = new BrightcoveParamCollection();

            methodParams.Add("token", Configuration.WriteToken);

            BrightcoveParamCollection parms = new BrightcoveParamCollection();

            parms.Add("method", method);
            parms.Add(_methodParamsKey, methodParams);

            return(parms);
        }
Beispiel #13
0
        private BrightcoveLogoOverlay DoAddLogoOverlay(BrightcoveLogoOverlay logoOverlay, FileUploadInfo fileUploadInfo, long videoId, string videoReferenceId)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(videoId, videoReferenceId, "video_id", "video_reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("add_logo_overlay",
                                                                         methodParams =>
            {
                methodParams.Add("logooverlay", logoOverlay);
                methodParams.Add(propName, propValue);
            });

            return(RunFilePost <BrightcoveResultContainer <BrightcoveLogoOverlay> >(parms, fileUploadInfo).Result);
        }
Beispiel #14
0
        /// <summary>
        /// Deletes a playlist, specified by playlist ID or reference ID.
        /// </summary>
        /// <param name="playlistId">The ID for the playlist to delete. Either a playlist ID or a reference ID must be supplied.</param>
        /// <param name="referenceId">The publisher-assigned reference ID of the playlist you want to delete. Either a playlist ID or a reference ID must be supplied.</param>
        /// <param name="cascade">Set this to true if you want to delete this playlist even if it is referenced by players. The playlist will be removed from all players in which it appears, then deleted.</param>
        private void DoDeletePlaylist(long playlistId, string referenceId, bool cascade)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(playlistId, referenceId, "playlist_id", "reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("delete_playlist",
                                                                         methodParams =>
            {
                methodParams.Add(propName, propValue);
                methodParams.Add("cascade", cascade.ToString().ToLower());
            });

            RunPost <BrightcoveResultContainer <long> >(parms);
        }
Beispiel #15
0
        /// <summary>
        /// Creates a new video by uploading a file.
        /// </summary>
        /// <param name="video">The metadata for the video you want to create.</param>
        /// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
        /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding.
        /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of
        /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param>
        /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be
        /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding
        /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created
        /// at the standard encoding rate and dimensions.</param>
        /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true,
        /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param>
        /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot
        /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param>
        /// <returns>The numeric ID of the newly created video.</returns>
        public long CreateVideo(BrightcoveVideo video, FileUploadInfo fileUploadInfo, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("create_video",
                                                                         methodParams =>
            {
                methodParams.Add("video", video);
                if (encodeTo != EncodeTo.None)
                {
                    methodParams.Add("encode_to", encodeTo.ToString().ToUpper());
                }
                methodParams.Add("create_multiple_renditions", createMultipleRenditions.ToString().ToLower());
                methodParams.Add("preserve_source_rendition", preserveSourceRendition.ToString().ToLower());
                methodParams.Add("H264NoProcessing ", h264NoProcessing.ToString().ToLower());
            });

            return(RunFilePost <BrightcoveResultContainer <long> >(parms, fileUploadInfo).Result);
        }
        /// <summary>
        /// Figures out whether the user wants to delete an audio track by ID or reference Id, then performs the action.
        /// </summary>
        /// <param name="audioTrackId">The ID of the <see cref="BrightcoveAudioTrack">audio track</see> you'd like to delete</param>
        /// <param name="referenceId">The reference ID of the <see cref="BrightcoveAudioTrack">audio track</see> you'd like to delete</param>
        /// <param name="cascade">If true, <see cref="BrightcoveAudioTrack">audio track</see> will be deleted even if it is part of a manual playlist or assigned to
        /// a player. The <see cref="BrightcoveAudioTrack">audio track</see> will be removed from all playlists and players in which it appears, then deleted.</param>
        /// <param name="deleteShares">Set this to true if you want also to delete shared copies of this <see cref="BrightcoveAudioTrack">audio track</see>. Note that
        /// this will delete all shared copies from your account, as well as from all accounts with which the <see cref="BrightcoveAudioTrack">audio track</see> has
        /// been shared, regardless of whether or not those accounts are currently using the <see cref="BrightcoveAudioTrack">audio track</see> in playlists or players.</param>
        private void DoDeleteAudioTrack(long audioTrackId, string referenceId, bool cascade, bool deleteShares)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(audioTrackId, referenceId, "audiotrack_id", "reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("delete_audiotrack",
                                                                         methodParams =>
            {
                methodParams.Add(propName, propValue);
                methodParams.Add("cascade", cascade.ToString().ToLower());
                methodParams.Add("delete_shares", deleteShares.ToString().ToLower());
            });

            RunPost <BrightcoveResultContainer <long> >(parms);
        }
        /// <summary>
        /// Add a thumbnail asset to the specified audio track.
        /// </summary>
        /// <param name="image">A BrightcoveImage containing the metadata for the image you'd like to create (or update).</param>
        /// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
        /// <param name="audioTrackId">The ID of the audio track to which you'd like to assign the image.</param>
        /// <param name="audioTrackReferenceId">The reference ID of the audio track to which you'd like to assign the image.</param>
        /// <param name="resize">Set this to false if you don't want your image to be automatically resized to the default size for its type.
        /// By default images will be resized.</param>
        /// <returns>The image that was added or updated.</returns>
        private BrightcoveImage DoAddAudioImage(BrightcoveImage image, FileUploadInfo fileUploadInfo, long audioTrackId, string audioTrackReferenceId, bool resize)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(audioTrackId, audioTrackReferenceId, "audiotrack_id", "audiotrack_reference_id", out propName, out propValue);

            BrightcoveParamCollection parms = CreateWriteParamCollection("add_audio_image",
                                                                         methodParams =>
            {
                methodParams.Add("image", image);
                methodParams.Add("resize", resize.ToString().ToLower());
                methodParams.Add(propName, propValue);
            });

            return(RunFilePost <BrightcoveResultContainer <BrightcoveImage> >(parms, fileUploadInfo).Result);
        }
Beispiel #18
0
        private BrightcoveCaptioning DoAddCaptioningWithFileUpload(FileUploadInfo captionFileUploadInfo, long videoId, string videoReferenceid, string filename)
        {
            string propName;
            object propValue;

            GetIdValuesForUpload(videoId, videoReferenceid, "video_id", "video_reference_id", out propName, out propValue);

            var captionSource = new BrightcoveCaptionSource {
                DisplayName = filename,
            };

            BrightcoveParamCollection parms = CreateWriteParamCollection("add_captioning",
                                                                         methodParams => {
                methodParams.Add(propName, propValue);
                methodParams.Add("caption_source", captionSource);
                methodParams.Add("filename", filename);
            });

            return(RunFilePost <BrightcoveResultContainer <BrightcoveCaptioning> >(parms, captionFileUploadInfo).Result);
        }
Beispiel #19
0
        /// <summary>
        /// Runs an API write (HTTP POST) that includes file data.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fileToUpload"></param>
        /// <param name="postParams"></param>
        /// <returns></returns>
        protected T RunFilePost <T>(BrightcoveParamCollection postParams, FileUploadInfo fileToUpload) where T : IJavaScriptConvertable
        {
            string json = Connector.GetFilePostResponseJson(SerializeJson(postParams), fileToUpload);

            return(DeserializeJson <T>(json));
        }
Beispiel #20
0
        /// <summary>
        /// Runs an API write (HTTP POST)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="postParams"></param>
        /// <returns></returns>
        protected T RunPost <T>(BrightcoveParamCollection postParams) where T : IJavaScriptConvertable
        {
            string responseJson = Connector.GetPostResponseJson(SerializeJson(postParams));

            return(DeserializeJson <T>(responseJson));
        }