Ejemplo n.º 1
0
        public void PlayVideo(string path, VideoPosition pos)
        {
            if (videoBox == null)
            {
                return;
            }
            videoPath = path;
            videoBox.gameObject.SetActive(!string.IsNullOrEmpty(path));
            if (videoTools)
            {
                videoTools.alpha = 1;
                videoTools.gameObject.SetActive(true);
            }

            if (pos == VideoPosition.Top)
            {
                videoBox.anchoredPosition = positionTop;
            }
            else if (pos == VideoPosition.Middle)
            {
                videoBox.anchoredPosition = positionMiddle;
            }
            else
            {
                videoBox.anchoredPosition = positionBottom;
            }
        }
 private void UpdateVideoPosition(int time)
 {
     if (!_blockVideoPositionValueChange)
     {
         VideoPosition.Invoke((MethodInvoker) delegate { VideoPosition.Value = time; });
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 加字幕 給Enum
 /// </summary>
 /// <param name="Text">字幕</param>
 /// <param name="Position">位置列舉</param>
 /// <param name="Color">文字顏色</param>
 /// <param name="Fontfile">C:/Windows/Fonts/ 下的 font file name</param>
 /// <param name="Fontsize">文字大小</param>
 /// <returns></returns
 public TextEffect(string Text, VideoPosition Position, Color color, string Fontfile = "msjh.ttc", int Fontsize = 24)
 {
     this.Text     = Text;
     this.Position = Position;
     this.Red      = color.R;
     this.Green    = color.G;
     this.Blue     = color.B;
     this.Fontfile = Fontfile;
     this.Fontsize = Fontsize;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 加字幕 給Enum
 /// </summary>
 /// <param name="Text">字幕</param>
 /// <param name="Position">位置列舉</param>
 /// <param name="Color">文字顏色</param>
 /// <param name="Fontfile">C:/Windows/Fonts/ 下的 font file name</param>
 /// <param name="Fontsize">文字大小</param>
 /// <returns></returns
 public TextEffect(string Text, VideoPosition Position, int Red, int Green, int Blue, string Fontfile = "msjh.ttc", int Fontsize = 24)
 {
     this.Text     = Text;
     this.Position = Position;
     this.Red      = Red;
     this.Green    = Green;
     this.Blue     = Blue;
     this.Fontfile = Fontfile;
     this.Fontsize = Fontsize;
 }
Ejemplo n.º 5
0
    void GetPosition()
    {
        VideoPosition listModul = new VideoPosition();

        DdlPosition.Items.Clear();
        for (int i = 0; i < listModul.Text.Length; i++)
        {
            DdlPosition.Items.Add(new ListItem(listModul.Text[i], listModul.Values[i]));
        }
    }
    string SetPosition(string value)
    {
        string        s         = "_";
        VideoPosition listModul = new VideoPosition();

        for (int i = 0; i < listModul.Values.Length; i++)
        {
            if (listModul.Values[i] == value)
            {
                s = listModul.Text[i];
                break;
            }
        }
        return(s);
    }
        private void FileBrowseButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(VlcPathText.Text))
            {
                return;
            }

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (_playStatus != PlayStatus.Stopped)
                {
                    StopButton_Click(null, null);
                }

                SelectedFileLabel.Visible = true;
                _filePath = openFileDialog.FileName;
                SelectedFileLabel.Text = openFileDialog.FileName;

                _videoInfo = VlcClient.GetFileInfo(openFileDialog.FileName);

                Text = _videoInfo.Title;

                LeftAudioTrack.Items.Clear();
                RightAudioTrack.Items.Clear();
                LeftAudioDevice.Items.Clear();
                RightAudioDevice.Items.Clear();

                foreach (var audioTrack in _videoInfo.AudioTracks)
                {
                    LeftAudioTrack.Items.Add(audioTrack);
                    RightAudioTrack.Items.Add(audioTrack);
                }

                foreach (var audioDevice in _videoInfo.AudioDevices)
                {
                    LeftAudioDevice.Items.Add(audioDevice.Key);
                    RightAudioDevice.Items.Add(audioDevice.Key);
                }

                VideoPosition.SetRange(0, _videoInfo.Duration);

                VideoTimeLabel.Visible = true;
                VideoPosition.Enabled  = true;
                UpdateVideoTime();

                ConfigurationPanel.Enabled = true;

                if (Properties.Settings.Default.DefaultLeftDevice >= 0 &&
                    Properties.Settings.Default.DefaultLeftDevice < LeftAudioDevice.Items.Count)
                {
                    LeftAudioDevice.SelectedIndex = Properties.Settings.Default.DefaultLeftDevice;
                }

                if (Properties.Settings.Default.DefaultRightDevice >= 0 &&
                    Properties.Settings.Default.DefaultRightDevice < RightAudioDevice.Items.Count)
                {
                    RightAudioDevice.SelectedIndex = Properties.Settings.Default.DefaultRightDevice;
                }

                if (Properties.Settings.Default.DefaultLeftTrack >= 0 &&
                    Properties.Settings.Default.DefaultLeftTrack < LeftAudioTrack.Items.Count)
                {
                    LeftAudioTrack.SelectedIndex = Properties.Settings.Default.DefaultLeftTrack;
                }

                if (Properties.Settings.Default.DefaultRightTrack >= 0 &&
                    Properties.Settings.Default.DefaultRightTrack < RightAudioTrack.Items.Count)
                {
                    RightAudioTrack.SelectedIndex = Properties.Settings.Default.DefaultRightTrack;
                }
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemService.
            LineItemService lineItemService =
                (LineItemService)user.GetService(DfpService.v201511.LineItemService);

            // Set the order that all created line items will belong to and the
            // video ad unit ID to target.
            long   orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
            string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

            // Set the custom targeting value ID representing the metadata
            // on the content to target. This would typically be from a key representing
            // a "genre" and a value representing something like "comedy". The value must
            // be from a key in a content metadata key hierarchy.
            long contentCustomTargetingValueId =
                long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

            // Create content targeting.
            ContentMetadataKeyHierarchyTargeting contentMetadataTargeting =
                new ContentMetadataKeyHierarchyTargeting();

            contentMetadataTargeting.customTargetingValueIds =
                new long[] { contentCustomTargetingValueId };

            ContentTargeting contentTargeting = new ContentTargeting();

            contentTargeting.targetedContentMetadata =
                new ContentMetadataKeyHierarchyTargeting[] { contentMetadataTargeting };

            // Create inventory targeting.
            InventoryTargeting inventoryTargeting = new InventoryTargeting();
            AdUnitTargeting    adUnitTargeting    = new AdUnitTargeting();

            adUnitTargeting.adUnitId           = targetedVideoAdUnitId;
            adUnitTargeting.includeDescendants = true;
            inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting };

            // Create video position targeting.
            VideoPosition videoPosition = new VideoPosition();

            videoPosition.positionType = VideoPositionType.PREROLL;
            VideoPositionTarget videoPositionTarget = new VideoPositionTarget();

            videoPositionTarget.videoPosition = videoPosition;
            VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();

            videoPositionTargeting.targetedPositions = new VideoPositionTarget[] { videoPositionTarget };

            // Create targeting.
            Targeting targeting = new Targeting();

            targeting.contentTargeting       = contentTargeting;
            targeting.inventoryTargeting     = inventoryTargeting;
            targeting.videoPositionTargeting = videoPositionTargeting;

            // Create local line item object.
            LineItem lineItem = new LineItem();

            lineItem.name          = "Video line item - " + this.GetTimeStamp();
            lineItem.orderId       = orderId;
            lineItem.targeting     = targeting;
            lineItem.lineItemType  = LineItemType.SPONSORSHIP;
            lineItem.allowOverbook = true;

            // Set the environment type to video.
            lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

            // Set the creative rotation type to optimized.
            lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

            // Create the master creative placeholder.
            CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
            Size size1 = new Size();

            size1.width                    = 400;
            size1.height                   = 300;
            size1.isAspectRatio            = false;
            creativeMasterPlaceholder.size = size1;

            // Create companion creative placeholders.
            CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
            Size size2 = new Size();

            size2.width         = 300;
            size2.height        = 250;
            size2.isAspectRatio = false;
            companionCreativePlaceholder1.size = size2;

            CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
            Size size3 = new Size();

            size3.width         = 728;
            size3.height        = 90;
            size3.isAspectRatio = false;
            companionCreativePlaceholder2.size = size3;

            // Set companion creative placeholders.
            creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
                companionCreativePlaceholder1, companionCreativePlaceholder2
            };

            // Set the size of creatives that can be associated with this line item.
            lineItem.creativePlaceholders = new CreativePlaceholder[] { creativeMasterPlaceholder };

            // Set delivery of video companions to optional.
            lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

            // Set the line item to run for one month.
            lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
            lineItem.endDateTime       =
                DateTimeUtilities.FromDateTime(System.DateTime.Now.AddMonths(1), "America/New_York");

            // Set the cost per day to $1.
            lineItem.costType = CostType.CPD;
            Money money = new Money();

            money.currencyCode   = "USD";
            money.microAmount    = 1000000L;
            lineItem.costPerUnit = money;

            // Set the percentage to be 100%.
            Goal goal = new Goal();

            goal.goalType        = GoalType.DAILY;
            goal.unitType        = UnitType.IMPRESSIONS;
            goal.units           = 100;
            lineItem.primaryGoal = goal;

            try {
                // Create the line item on the server.
                LineItem[] createdLineItems = lineItemService.createLineItems(new LineItem[] { lineItem });

                foreach (LineItem createdLineItem in createdLineItems)
                {
                    Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
                                      "named \"{2}\" was created.", createdLineItem.id, createdLineItem.orderId,
                                      createdLineItem.name);
                }
            } catch (Exception e) {
                Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
                                  e.Message);
            }
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the LineItemService.
      LineItemService lineItemService =
          (LineItemService) user.GetService(DfpService.v201508.LineItemService);

      // Set the order that all created line items will belong to and the
      // video ad unit ID to target.
      long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
      string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

      // Set the custom targeting value ID representing the metadata
      // on the content to target. This would typically be from a key representing
      // a "genre" and a value representing something like "comedy". The value must
      // be from a key in a content metadata key hierarchy.
      long contentCustomTargetingValueId =
          long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

      // Create content targeting.
      ContentMetadataKeyHierarchyTargeting contentMetadataTargeting =
          new ContentMetadataKeyHierarchyTargeting();
      contentMetadataTargeting.customTargetingValueIds =
          new long[] {contentCustomTargetingValueId};

      ContentTargeting contentTargeting = new ContentTargeting();
      contentTargeting.targetedContentMetadata =
          new ContentMetadataKeyHierarchyTargeting[] {contentMetadataTargeting};

      // Create inventory targeting.
      InventoryTargeting inventoryTargeting = new InventoryTargeting();
      AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
      adUnitTargeting.adUnitId = targetedVideoAdUnitId;
      adUnitTargeting.includeDescendants = true;
      inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] {adUnitTargeting};

      // Create video position targeting.
      VideoPosition videoPosition = new VideoPosition();
      videoPosition.positionType = VideoPositionType.PREROLL;
      VideoPositionTarget videoPositionTarget = new VideoPositionTarget();
      videoPositionTarget.videoPosition = videoPosition;
      VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
      videoPositionTargeting.targetedPositions = new VideoPositionTarget[] {videoPositionTarget};

      // Create targeting.
      Targeting targeting = new Targeting();
      targeting.contentTargeting = contentTargeting;
      targeting.inventoryTargeting = inventoryTargeting;
      targeting.videoPositionTargeting = videoPositionTargeting;

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.name = "Video line item - " + this.GetTimeStamp();
      lineItem.orderId = orderId;
      lineItem.targeting = targeting;
      lineItem.lineItemType = LineItemType.SPONSORSHIP;
      lineItem.allowOverbook = true;

      // Set the environment type to video.
      lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

      // Set the creative rotation type to optimized.
      lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

      // Create the master creative placeholder.
      CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
      Size size1 = new Size();
      size1.width = 400;
      size1.height = 300;
      size1.isAspectRatio = false;
      creativeMasterPlaceholder.size = size1;

      // Create companion creative placeholders.
      CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
      Size size2 = new Size();
      size2.width = 300;
      size2.height = 250;
      size2.isAspectRatio = false;
      companionCreativePlaceholder1.size = size2;

      CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
      Size size3 = new Size();
      size3.width = 728;
      size3.height = 90;
      size3.isAspectRatio = false;
      companionCreativePlaceholder2.size = size3;

      // Set companion creative placeholders.
      creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
          companionCreativePlaceholder1, companionCreativePlaceholder2};

      // Set the size of creatives that can be associated with this line item.
      lineItem.creativePlaceholders = new CreativePlaceholder[] {creativeMasterPlaceholder};

      // Set delivery of video companions to optional.
      lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

      // Set the line item to run for one month.
      lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
      lineItem.endDateTime =
          DateTimeUtilities.FromDateTime(System.DateTime.Now.AddMonths(1), "America/New_York");

      // Set the cost per day to $1.
      lineItem.costType = CostType.CPD;
      Money money = new Money();
      money.currencyCode = "USD";
      money.microAmount = 1000000L;
      lineItem.costPerUnit = money;

      // Set the percentage to be 100%.
      Goal goal = new Goal();
      goal.goalType = GoalType.DAILY;
      goal.unitType = UnitType.IMPRESSIONS;
      goal.units = 100;
      lineItem.primaryGoal = goal;

      try {
        // Create the line item on the server.
        LineItem[] createdLineItems = lineItemService.createLineItems(new LineItem[] {lineItem});

        foreach (LineItem createdLineItem in createdLineItems) {
          Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
              "named \"{2}\" was created.", createdLineItem.id, createdLineItem.orderId,
              createdLineItem.name);
        }
      } catch (Exception e) {
        Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
            e.Message);
      }
    }
Ejemplo n.º 10
0
 private void Button_Click_9(object sender, RoutedEventArgs e)
 {
     subtitle.VerticalAlignment   = VerticalAlignment.Bottom;
     subtitle.HorizontalAlignment = HorizontalAlignment.Right;
     this._textPosition           = VideoPosition.ButtomRight;
 }
Ejemplo n.º 11
0
 private void Button_Click_5(object sender, RoutedEventArgs e)
 {
     subtitle.VerticalAlignment   = VerticalAlignment.Center;
     subtitle.HorizontalAlignment = HorizontalAlignment.Center;
     this._textPosition           = VideoPosition.Center;
 }
Ejemplo n.º 12
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     subtitle.VerticalAlignment   = VerticalAlignment.Top;
     subtitle.HorizontalAlignment = HorizontalAlignment.Left;
     this._textPosition           = VideoPosition.TopLeft;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemService.
            LineItemService lineItemService =
                (LineItemService)user.GetService(DfpService.v201311.LineItemService);

            // Set the order that all created line items will belong to and the
            // video ad unit ID to target.
            long   orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
            string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

            // Set the custom targeting key ID and value ID representing the metadata
            // on the content to target. This would typically be a key representing
            // a "genre" and a value representing something like "comedy".
            long contentCustomTargetingKeyId =
                long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_KEY_ID_HERE"));
            long contentCustomTargetingValueId =
                long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

            // Create custom criteria for the content metadata targeting.
            CustomCriteria contentCustomCriteria = new CustomCriteria();

            contentCustomCriteria.keyId     = contentCustomTargetingKeyId;
            contentCustomCriteria.valueIds  = new long[] { contentCustomTargetingValueId };
            contentCustomCriteria.@operator = CustomCriteriaComparisonOperator.IS;

            // Create custom criteria set.
            CustomCriteriaSet customCriteriaSet = new CustomCriteriaSet();

            customCriteriaSet.children = new CustomCriteriaNode[] { contentCustomCriteria };

            // Create inventory targeting.
            InventoryTargeting inventoryTargeting = new InventoryTargeting();
            AdUnitTargeting    adUnitTargeting    = new AdUnitTargeting();

            adUnitTargeting.adUnitId           = targetedVideoAdUnitId;
            adUnitTargeting.includeDescendants = true;
            inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting };

            // Create video position targeting.
            VideoPosition videoPosition = new VideoPosition();

            videoPosition.positionType = VideoPositionType.PREROLL;
            VideoPositionTarget videoPositionTarget = new VideoPositionTarget();

            videoPositionTarget.videoPosition = videoPosition;
            VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();

            videoPositionTargeting.targetedPositions = new VideoPositionTarget[] { videoPositionTarget };

            // Create targeting.
            Targeting targeting = new Targeting();

            targeting.customTargeting        = customCriteriaSet;
            targeting.inventoryTargeting     = inventoryTargeting;
            targeting.videoPositionTargeting = videoPositionTargeting;

            // Create local line item object.
            LineItem lineItem = new LineItem();

            lineItem.name          = "Video line item - " + this.GetTimeStamp();
            lineItem.orderId       = orderId;
            lineItem.targeting     = targeting;
            lineItem.lineItemType  = LineItemType.SPONSORSHIP;
            lineItem.allowOverbook = true;

            // Set the environment type to video.
            lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

            // Set the creative rotation type to optimized.
            lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

            // Create the master creative placeholder.
            CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
            Size size1 = new Size();

            size1.width                    = 400;
            size1.height                   = 300;
            size1.isAspectRatio            = false;
            creativeMasterPlaceholder.size = size1;

            // Create companion creative placeholders.
            CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
            Size size2 = new Size();

            size2.width         = 300;
            size2.height        = 250;
            size2.isAspectRatio = false;
            companionCreativePlaceholder1.size = size2;

            CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
            Size size3 = new Size();

            size3.width         = 728;
            size3.height        = 90;
            size3.isAspectRatio = false;
            companionCreativePlaceholder2.size = size3;

            // Set companion creative placeholders.
            creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
                companionCreativePlaceholder1, companionCreativePlaceholder2
            };

            // Set the size of creatives that can be associated with this line item.
            lineItem.creativePlaceholders = new CreativePlaceholder[] { creativeMasterPlaceholder };

            // Set delivery of video companions to optional.
            lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

            // Set the length of the line item to run.
            lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
            lineItem.endDateTime       = DateTimeUtilities.FromString("20120901 00:00:00");

            // Set the cost per day to $1.
            lineItem.costType = CostType.CPD;
            Money money = new Money();

            money.currencyCode   = "USD";
            money.microAmount    = 1000000L;
            lineItem.costPerUnit = money;

            // Set the percentage to be 100%.
            lineItem.unitsBought = 100;

            try {
                // Create the line item on the server.
                lineItem = lineItemService.createLineItem(lineItem);

                if (lineItem != null)
                {
                    Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
                                      "named \"{2}\" was created.", lineItem.id, lineItem.orderId, lineItem.name);
                }
                else
                {
                    Console.WriteLine("No line item created.");
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
                                  ex.Message);
            }
        }