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.
var 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