示例#1
0
		public static string ToJSON(this RPCError jsonRPC) {

			Builder rpc = new Builder(",", "{", "}");
			rpc.AppendObject("name", jsonRPC.name);
			rpc.AppendObject("message", jsonRPC.message);
			rpc.AppendObject("code", jsonRPC.code);

			return rpc.ToString();
		}
示例#2
0
		public static string ToJSON(this RPCResponse jsonRPC) {

			Builder rpc = new Builder(",", "{", "}");
			rpc.AppendObject("result", "{" + jsonRPC.result + "}");
			string error = (!jsonRPC.error.Equals("null")) ? jsonRPC.error.ToJSON() : "null";
			rpc.AppendObject("error", error);
			rpc.AppendObject("id", jsonRPC.id);

			return rpc.ToString();
		}
示例#3
0
		public static string ToJSON(this RPCRequest jsonRPC) {

			Builder rpc = new Builder(",", "{", "}");

			rpc.AppendField("method", jsonRPC.method);
			string parameters = (!jsonRPC.parameters.Equals("null")) ? "{" + jsonRPC.parameters + "}" : "null";
			rpc.AppendObject("params", parameters);
			rpc.AppendObject("id", jsonRPC.id);

			return rpc.ToString();
		}
      private RPCResponse DeleteCaptioning(long video_id, string video_reference_id)
      {
			Dictionary<string, object> postParams = new Dictionary<string, object>();

         Builder builder = new Builder()
            .AppendField("token", Account.WriteToken.Value);

         // Either a video_id or video_reference_id is required
         if (video_id > 0)
            builder.Append(",").AppendField("video_id", video_id);
         else if (!string.IsNullOrEmpty(video_reference_id))
            builder.Append(",").AppendField("video_reference_id", video_reference_id);
         else
            throw new System.ArgumentException("A video_id or video_reference_id is required for delete_captioning");

			RPCRequest rpc = new RPCRequest();
			rpc.method = "delete_captioning";
         rpc.parameters = builder.ToString();
			postParams.Add("json", rpc.ToJSON());

			// Get the JSon reader returned from the APIRequest
			RPCResponse rpcr = BCAPIRequest.ExecuteWrite(postParams, this.Account);

         return rpcr;
      }
      /// <summary>
      /// Adds a Captioning to an existing video
      /// http://docs.brightcove.com/en/media/reference.html#Video_Write
      /// The captions can either be uploaded to BC or be referred to by an external url
      /// BrightCove supports the DFXP and SMPTE-TT formats
      /// http://support.brightcove.com/en/docs/using-captions-smart-player-api
      /// </summary>
      /// <param name="caption_source">Metadata about the captions</param>
      /// <param name="options">Parameters (options) including the ID of the video that MUST be set</param>
      /// <param name="captions">a buffer containing DFXP or SMPTE-TT caption data</param>
      /// <returns>the captionSources object</returns>
      public RPCResponse<BCCaptionSources> AddCaptioning(BCCaptionSource caption_source, BCAddCaptioningOptions options, byte[] captions)
      {
			Dictionary<string, object> postParams = new Dictionary<string, object>();

         Builder builder = new Builder()
            .AppendObject("caption_source", caption_source.ToJSON(JSONType.Create))
            .Append(",").AppendField("token", Account.WriteToken.Value);

         if (!string.IsNullOrEmpty(options.filename))
            builder.Append(",").AppendField("filename", options.filename);

         if (options.maxsize > 0)
            builder.Append(",").AppendField("maxsize", options.maxsize);

         if (!string.IsNullOrEmpty(options.file))
            throw new System.ArgumentException("The file property not supported.  Pass the captions in as a byte array.");

         if (!string.IsNullOrEmpty(options.file_checksum))
            builder.Append(",").AppendField("file_checksum", options.file_checksum);

         // Either a video_id or video_reference_id is required
         if (options.video_id > 0)
            builder.Append(",").AppendField("video_id", options.video_id);
         else if (!string.IsNullOrEmpty(options.video_reference_id))
            builder.Append(",").AppendField("video_reference_id", options.video_reference_id);
         else
            throw new System.ArgumentException("A video_id or video_reference_id is required for add_captioning");

			RPCRequest rpc = new RPCRequest();
			rpc.method = "add_captioning";
         rpc.parameters = builder.ToString();
			postParams.Add("json", rpc.ToJSON());

         postParams.Add("file", new UploadBufferParameter(captions, "captions.dfxp"));

			// Get the JSon reader returned from the APIRequest
			// RPCResponse<BCCaptionSources> rpcr = BCAPIRequest.ExecuteWriteFile<BCCaptionSources>(postParams, this.Account, @"C:\dev\svn\BrightCove\TestFormApp\sample_captions.dfxp");
			RPCResponse<BCCaptionSources> rpcr = BCAPIRequest.ExecuteWriteNew<BCCaptionSources>(postParams, this.Account);

         return rpcr;
      }