コード例 #1
0
        /// <summary>
        /// 新增其他类型永久素材
        /// </summary>
        /// <param name="filePathName">指定包含完整路径的文件名</param>
        /// <param name="videoDescription">上传视频素材时,需提供视频的描述信息</param>
        /// <returns>新增永久素材的结果</returns>
        public WeChatResult <MaterialResult> AddMaterial(string filePathName, VideoDescription videoDescription = null)
        {
            string accessToken = connect.GetAccessToken();
            string type        = MimeMapping.GetMimeMapping(filePathName); //获取文件的Mime-Type

            type = type.Substring(0, type.IndexOf('/'));                   //提取Mime-Type的前部分
            string fileName = Path.GetFileName(filePathName);

            using (Stream fileStream = new FileStream(filePathName, FileMode.Open))
            {
                if ("image".Equals(type) && fileStream.Length < 64 * 1024)
                {
                    type = "thumb";//如果文件属于图片,而且小于64KB的,类型改成缩略图(thumb)
                }
                else if ("audio".Equals(type))
                {
                    type = "voice";
                }
                string          url       = $"https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={accessToken}&type={type}";
                UploadFileParam fileParam = new UploadFileParam(url, fileName, fileStream);
                if (videoDescription != null)
                {
                    fileParam.PostParameters.Add("title", videoDescription.title);
                    fileParam.PostParameters.Add("introduction", videoDescription.introduction);
                }
                string resultStr = SimulateRequest.UploadFile(fileParam);
                WeChatResult <MaterialResult> weChatResult = new WeChatResult <MaterialResult>(resultStr);
                if (weChatResult.errcode != WeChatErrorCode.SUCCESS)
                {
                    SystemLogHelper.Warn(MethodBase.GetCurrentMethod(), $"上传图文消息内的图片获取URLGetUrlByUpdateImg,微信服务报错:{weChatResult}");
                }
                return(weChatResult);
            }
        }
コード例 #2
0
        public void Return_False_When_Compare_VideoDescription_With_Null_Value()
        {
            // given
            VideoDescription videoDescriptionOne = new VideoDescription(SomeVideoDescription);

            // when
            bool result = videoDescriptionOne.Equals(null);

            // then
            result.Should().BeFalse();
        }
コード例 #3
0
        public void Return_False_When_Compare_VideoDescription_With_Different_Value()
        {
            // given
            VideoDescription videoDescriptionOne = new VideoDescription(SomeVideoDescription);
            VideoDescription videoDescriptionTwo = new VideoDescription(AnotherVideoDescription);

            // when
            bool result = videoDescriptionOne.Equals(videoDescriptionTwo);

            // then
            result.Should().BeFalse();
        }
コード例 #4
0
        public void Return_True_When_Compare_VideoDescription_With_Same_Value()
        {
            // given
            VideoDescription videoDescriptionOne = new VideoDescription(SomeVideoDescription);
            VideoDescription videoDescriptionTwo = new VideoDescription(SomeVideoDescription);

            // when
            bool result = videoDescriptionOne.Equals(videoDescriptionTwo);

            // then
            result.Should().BeTrue();
        }
コード例 #5
0
 private Video(
     VideoId id,
     VideoTitle title,
     VideoDescription description,
     VideoAuthor author,
     VideoCreatedAT createdAt
     )
 {
     this.id          = id;
     this.title       = title;
     this.description = description;
     this.author      = author;
     this.createdAt   = createdAt;
 }
コード例 #6
0
ファイル: DetailsPage.xaml.cs プロジェクト: 27043591/GUI-
 private void VideoSectionAnimate()
 {
     VideoButton.Offset(offsetY: 40, duration: 0).Then().Fade(1).Offset().Start();
     VideoDescription.Offset(offsetY: 40, duration: 0).Then().Fade(1).Offset().Start();
 }
コード例 #7
0
 private bool Equals(VideoDescription other)
 {
     return(string.Equals(Value, other.Value));
 }
コード例 #8
0
        static void Main(string[] args)
        {
            String mediaConvertRole = "arn:aws:iam::378090785532:role/TurnerMediaConvertRole";
            String fileInput        = "s3://mediaconvertin/B83UV-A-03-EL-COMANDANTE---EL-COMANDANTE-ae98f140.mov";
            String fileOutput       = "s3://mediaconvertout/Salida.mov";
            AmazonMediaConvertClient client;
            // Once you know what your customer endpoint is, set it here
            String mediaConvertEndpoint = "";

            // If we do not have our customer-specific endpoint
            if (String.IsNullOrEmpty(mediaConvertEndpoint))
            {
                //Amazon.Runtime.AWSCredentials c = new Amazon.Runtime.AWSCredentials();
                // Obtain the customer-specific MediaConvert endpoint
                client = new
                         AmazonMediaConvertClient("AKIAJ35VKR7CZVBCL2GQ", "L2cnZrGPhvCD17X8hAbk4w2rd1sjPVtX8BE7OOmv", Amazon.RegionEndpoint.USEast1);
                DescribeEndpointsRequest describeRequest = new
                                                           DescribeEndpointsRequest();
                DescribeEndpointsResponse describeResponse =
                    client.DescribeEndpointsAsync(describeRequest).Result;
                mediaConvertEndpoint = describeResponse.Endpoints[0].Url;
            }
            // Since we have a service url for MediaConvert, we do not
            // need to set RegionEndpoint. If we do, the ServiceURL will
            // be overwritten

            client = new
                     AmazonMediaConvertClient("AKIAJ35VKR7CZVBCL2GQ", "L2cnZrGPhvCD17X8hAbk4w2rd1sjPVtX8BE7OOmv", Amazon.RegionEndpoint.USEast1);

            NetworkCredential cred = new NetworkCredential("AKIAJ35VKR7CZVBCL2GQ", "L2cnZrGPhvCD17X8hAbk4w2rd1sjPVtX8BE7OOmv");


            AmazonMediaConvertConfig mcConfig = new AmazonMediaConvertConfig
            {
                ServiceURL       = mediaConvertEndpoint,
                ProxyCredentials = cred
                                   //                ProxyCredentials = client
            };

            AmazonMediaConvertClient mcClient         = new AmazonMediaConvertClient(mcConfig);
            CreateJobRequest         createJobRequest = new CreateJobRequest();

            createJobRequest.Role = mediaConvertRole;
            createJobRequest.UserMetadata.Add("Customer", "Amazon");

            #region Create job settings
            JobSettings jobSettings = new JobSettings();
            jobSettings.AdAvailOffset         = 0;
            jobSettings.TimecodeConfig        = new TimecodeConfig();
            jobSettings.TimecodeConfig.Source = TimecodeSource.EMBEDDED;
            createJobRequest.Settings         = jobSettings;

            #region OutputGroup
            OutputGroup ofg = new OutputGroup();
            ofg.Name = "File Group";
            ofg.OutputGroupSettings      = new OutputGroupSettings();
            ofg.OutputGroupSettings.Type = OutputGroupType.FILE_GROUP_SETTINGS;
            ofg.OutputGroupSettings.FileGroupSettings             = new FileGroupSettings();
            ofg.OutputGroupSettings.FileGroupSettings.Destination = fileOutput;
            Output output = new Output();
            output.NameModifier = "_1";
            #region VideoDescription
            VideoDescription vdes = new VideoDescription();
            output.VideoDescription = vdes;
            vdes.ScalingBehavior    = ScalingBehavior.DEFAULT;
            vdes.TimecodeInsertion  = VideoTimecodeInsertion.DISABLED;
            vdes.AntiAlias          = AntiAlias.ENABLED;
            vdes.Sharpness          = 50;
            vdes.AfdSignaling       = AfdSignaling.NONE;

            vdes.DropFrameTimecode   = DropFrameTimecode.ENABLED;
            vdes.RespondToAfd        = RespondToAfd.NONE;
            vdes.ColorMetadata       = ColorMetadata.INSERT;
            vdes.CodecSettings       = new VideoCodecSettings();
            vdes.CodecSettings.Codec = VideoCodec.H_264;
            H264Settings h264 = new H264Settings();
            h264.InterlaceMode         = H264InterlaceMode.PROGRESSIVE;
            h264.NumberReferenceFrames = 3;
            h264.Syntax                      = H264Syntax.DEFAULT;
            h264.Softness                    = 0;
            h264.GopClosedCadence            = 1;
            h264.GopSize                     = 90;
            h264.Slices                      = 1;
            h264.GopBReference               = H264GopBReference.DISABLED;
            h264.SlowPal                     = H264SlowPal.DISABLED;
            h264.SpatialAdaptiveQuantization =
                H264SpatialAdaptiveQuantization.ENABLED;
            h264.TemporalAdaptiveQuantization =
                H264TemporalAdaptiveQuantization.ENABLED;
            h264.FlickerAdaptiveQuantization =
                H264FlickerAdaptiveQuantization.DISABLED;
            h264.EntropyEncoding              = H264EntropyEncoding.CABAC;
            h264.Bitrate                      = 5000000;
            h264.FramerateControl             = H264FramerateControl.SPECIFIED;
            h264.RateControlMode              = H264RateControlMode.CBR;
            h264.CodecProfile                 = H264CodecProfile.MAIN;
            h264.Telecine                     = H264Telecine.NONE;
            h264.MinIInterval                 = 0;
            h264.AdaptiveQuantization         = H264AdaptiveQuantization.HIGH;
            h264.CodecLevel                   = H264CodecLevel.AUTO;
            h264.FieldEncoding                = H264FieldEncoding.PAFF;
            h264.SceneChangeDetect            = H264SceneChangeDetect.ENABLED;
            h264.QualityTuningLevel           = H264QualityTuningLevel.SINGLE_PASS;
            h264.FramerateConversionAlgorithm =
                H264FramerateConversionAlgorithm.DUPLICATE_DROP;
            h264.UnregisteredSeiTimecode = H264UnregisteredSeiTimecode.DISABLED;
            h264.GopSizeUnits            = H264GopSizeUnits.FRAMES;
            h264.ParControl = H264ParControl.SPECIFIED;
            h264.NumberBFramesBetweenReferenceFrames = 2;
            h264.RepeatPps            = H264RepeatPps.DISABLED;
            h264.FramerateNumerator   = 30;
            h264.FramerateDenominator = 1;
            h264.ParNumerator         = 1;
            h264.ParDenominator       = 1;
            output.VideoDescription.CodecSettings.H264Settings = h264;
            #endregion VideoDescription
            #region AudioDescription
            AudioDescription ades = new AudioDescription();
            ades.LanguageCodeControl = AudioLanguageCodeControl.FOLLOW_INPUT;
            // This name matches one specified in the Inputs below
            ades.AudioSourceName     = "Audio Selector 1";
            ades.CodecSettings       = new AudioCodecSettings();
            ades.CodecSettings.Codec = AudioCodec.AAC;
            AacSettings aac = new AacSettings();
            aac.AudioDescriptionBroadcasterMix =
                AacAudioDescriptionBroadcasterMix.NORMAL;
            aac.RateControlMode            = AacRateControlMode.CBR;
            aac.CodecProfile               = AacCodecProfile.LC;
            aac.CodingMode                 = AacCodingMode.CODING_MODE_2_0;
            aac.RawFormat                  = AacRawFormat.NONE;
            aac.SampleRate                 = 48000;
            aac.Specification              = AacSpecification.MPEG4;
            aac.Bitrate                    = 64000;
            ades.CodecSettings.AacSettings = aac;
            output.AudioDescriptions.Add(ades);

            #endregion AudioDescription
            #region Mp4 Container
            output.ContainerSettings           = new ContainerSettings();
            output.ContainerSettings.Container = ContainerType.MP4;
            Mp4Settings mp4 = new Mp4Settings();
            mp4.CslgAtom      = Mp4CslgAtom.INCLUDE;
            mp4.FreeSpaceBox  = Mp4FreeSpaceBox.EXCLUDE;
            mp4.MoovPlacement = Mp4MoovPlacement.PROGRESSIVE_DOWNLOAD;
            output.ContainerSettings.Mp4Settings = mp4;
            #endregion Mp4 Container
            ofg.Outputs.Add(output);
            createJobRequest.Settings.OutputGroups.Add(ofg);
            #endregion OutputGroup
            #region Input
            Input input = new Input();
            input.FilterEnable   = InputFilterEnable.AUTO;
            input.PsiControl     = InputPsiControl.USE_PSI;
            input.FilterStrength = 0;
            input.DeblockFilter  = InputDeblockFilter.DISABLED;
            input.DenoiseFilter  = InputDenoiseFilter.DISABLED;
            input.TimecodeSource = InputTimecodeSource.EMBEDDED;
            input.FileInput      = fileInput;
            AudioSelector audsel = new AudioSelector();
            audsel.Offset           = 0;
            audsel.DefaultSelection = AudioDefaultSelection.NOT_DEFAULT;
            audsel.ProgramSelection = 1;
            audsel.SelectorType     = AudioSelectorType.TRACK;
            audsel.Tracks.Add(1);
            input.AudioSelectors.Add("Audio Selector 1", audsel);
            input.VideoSelector            = new VideoSelector();
            input.VideoSelector.ColorSpace = ColorSpace.FOLLOW;
            createJobRequest.Settings.Inputs.Add(input);

            #endregion Input
            #endregion Create job settings
            try
            {
                CreateJobResponse createJobResponse =
                    mcClient.CreateJobAsync(createJobRequest).Result;
                Console.WriteLine("Job Id: {0}", createJobResponse.Job.Id);
            }
            catch (BadRequestException bre)
            {
                // If the enpoint was bad
                if (bre.Message.StartsWith("You must use the customer-"))
                {
                    // The exception contains the correct endpoint; extract it
                    mediaConvertEndpoint = bre.Message.Split('\'')[1];
                    // Code to retry query
                }
            }
        }