jmona789
jmona789

Reputation: 2839

YouTube API: Uncaught SyntaxError: missing ) after argument list

I'm using the YouTube API and I keep getting "Uncaught SyntaxError: missing ) after argument list" for the second line of code here:

$(".addVideoUrlBtn").on("click", function(){
 player.loadVideoByUrl(mediaContentUrl: videoUrl, 
 startSeconds:0, 
 suggestedQuality:"large"):Void
})

The code is practically copied and pasted from YouTube api docs here: https://developers.google.com/youtube/iframe_api_reference so I'm not sure why I'm getting an error.

Upvotes: 0

Views: 186

Answers (1)

Tyler Sebastian
Tyler Sebastian

Reputation: 9468

you're taking the docs too literally. The examples shown are a) not valid js (because they aren't supposed to be) b) showing the TYPES of expected argument

when they say

player.cueVideoById(videoId:String,
                    startSeconds:Number,
                    suggestedQuality:String):Void

they mean that the function player.cueVideoById takes arguments videoId, startSeconds, and suggestedQuality which are a String, Number, and String respectively and that its return type is Void (nothing)

$(".addVideoUrlBtn").on("click", function(){
 player.loadVideoByUrl(url, 0, "large")
})

is that you want

Upvotes: 1

Related Questions