Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,25 @@ trait YouTubePartnerApi { this: YouTubeAccess with Logging =>
atomId: String,
enableMidroll: Boolean
): Either[VideoUpdateError, String] = {
// All possible formats can be found on YouTube developer docs: https://developers.google.com/youtube/partner/docs/v1/videoAdvertisingOptions#properties
val formats = Seq("standard_instream", "trueview_instream", "display")

// see https://developers.google.com/youtube/partner/docs/v1/videoAdvertisingOptions#breakPosition[]
val breakPositions = Seq("preroll") ++ Option.when(enableMidroll)("midroll")
// All possible formats could previously be found on YouTube developer docs: https://developers.google.com/youtube/partner/docs/v1/videoAdvertisingOptions#properties
// They're not there any more, and instead the docs imply that they no longer need to be set. That doesn't
// seem to actually be the case (as of 26th Jan 2026), and standard_instream and trueview_instream need to
// be enabled for non-skippable and skippable adverts respectively to be shown.
val adFormats = Seq("standard_instream", "trueview_instream").asJava

// https://developers.google.com/youtube/partner/reference/rest/v1/videoAdvertisingOptions#VideoAdvertisingOption.FIELDS.ad_breaks
val adBreaks = Seq(
new AdBreak().setPosition("preroll"),
// Midroll ads are not in this list, but will be enabled and generated by setting
// the "auto-generated breaks" flag to true below.
new AdBreak().setPosition("postroll")
).asJava

val advertisingOption: VideoAdvertisingOption =
new VideoAdvertisingOption()
.setAdFormats(formats.asJava)
.setAutoGeneratedBreaks(true)
.setBreakPosition(breakPositions.asJava)
.setAdFormats(adFormats)
.setAdBreaks(adBreaks)
.setAutoGeneratedBreaks(enableMidroll)

try {
MAMLogger.info(
Expand Down
Loading