Class VideoItem

VideoItem

用于显示视频的布局项。可以通过 Form 访问或创建项目。

// Open a form by ID and add three new video items, using a long URL,
// a short URL, and a video ID.
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
form.addVideoItem()
    .setTitle('Video Title')
    .setHelpText('Video Caption')
    .setVideoUrl('www.youtube.com/watch?v=1234abcdxyz');

form.addVideoItem()
    .setTitle('Video Title')
    .setHelpText('Video Caption')
    .setVideoUrl('youtu.be/1234abcdxyz');

form.addVideoItem()
    .setTitle('Video Title')
    .setHelpText('Video Caption')
    .setVideoUrl('1234abcdxyz');

方法

方法返回类型简介
duplicate()VideoItem创建相应商品的副本并将其附加到表单末尾。
getAlignment()Alignment获取视频的水平对齐方式。
getHelpText()String获取商品的帮助文本(有时称为布局项(如 ImageItemsPageBreakItemsSectionHeaderItems)的说明文本)。
getId()Integer获取商品的唯一标识符。
getIndex()Integer获取相应项在表单中所有项中的索引。
getTitle()String获取商品的标题(如果是 SectionHeaderItem,则有时称为标题文字)。
getType()ItemType获取以 ItemType 表示的商品类型。
getWidth()Integer获取视频的宽度(以像素为单位)。
setAlignment(alignment)VideoItem设置视频的水平对齐方式。
setHelpText(text)VideoItem设置商品的帮助文本(有时称为布局项的说明文本,例如 ImageItemsPageBreakItemsSectionHeaderItems)。
setTitle(title)VideoItem设置商品的标题(如果是 SectionHeaderItem,有时称为标题文字)。
setVideoUrl(youtubeUrl)VideoItem根据给定的 YouTube 网址或 YouTube 视频 ID 设置视频本身。
setWidth(width)VideoItem设置视频的宽度(以像素为单位)。

详细文档

duplicate()

创建相应商品的副本并将其附加到表单末尾。

返回

VideoItem - 相应 VideoItem 的副本,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getAlignment()

获取视频的水平对齐方式。

返回

Alignment - 水平对齐方式

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getHelpText()

获取商品的帮助文本(有时称为布局项(如 ImageItemsPageBreakItemsSectionHeaderItems)的说明文本)。

返回

String - 推荐项的帮助文本或说明文本

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getId()

获取商品的唯一标识符。

返回

Integer - 商品的 ID

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getIndex()

获取相应项在表单中所有项中的索引。

返回

Integer - 商品的索引

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getTitle()

获取商品的标题(如果是 SectionHeaderItem,则有时称为标题文字)。

返回

String - 商品的商品名或标题文字

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getType()

获取以 ItemType 表示的商品类型。

返回

ItemType - 商品的类型

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getWidth()

获取视频的宽度(以像素为单位)。

返回

Integer - 宽度(以像素为单位)

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setAlignment(alignment)

设置视频的水平对齐方式。

参数

名称类型说明
alignmentAlignment水平对齐方式

返回

VideoItem - 此 VideoItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setHelpText(text)

设置商品的帮助文本(有时称为布局项的说明文本,例如 ImageItemsPageBreakItemsSectionHeaderItems)。

参数

名称类型说明
textString新帮助文本

返回

VideoItem - 此 VideoItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setTitle(title)

设置商品的标题(如果是 SectionHeaderItem,有时称为标题文字)。

参数

名称类型说明
titleString新标题或标题文字

返回

VideoItem - 此 VideoItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setVideoUrl(youtubeUrl)

根据给定的 YouTube 网址或 YouTube 视频 ID 设置视频本身。

参数

名称类型说明
youtubeUrlStringYouTube 网址或 ID

返回

VideoItem - 此 VideoItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setWidth(width)

设置视频的宽度(以像素为单位)。只能设置视频的宽度。系统会自动设置高度,以保持视频的比例。

参数

名称类型说明
widthInteger宽度(以像素为单位)

返回

VideoItem - 此 VideoItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms