Skip to content

iocat/youtube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

youtube

Gopherjs Bindings for Youtube's Iframe API documented @ https://developers.google.com/youtube/iframe_api_reference

Test and example page can be accessed by gopherjs serve.

Usage: Sample code is in the example package

const playerID            = "playerID"

func main() {
	// 1. Add the Youtube script to your header
	yourAddScriptFunc(youtubeIframeAPISrc)

	// 2. Place the player container as a div in your html with a predefined id
	var app = &App{playerID: playerID}
	vecty.RenderBody(app)

	// 3. Initialize the player when the Youtube API's done loading
	js.Global.Set("onYouTubeIframeAPIReady", func() {
		// Create and set the initial properties of the player (check the document
		// for the specific fields)
		var props = youtube.NewProperties()
		props.Width = 640
		props.Height = 390
		props.VideoID = "dQw4w9WgXcQ"
		props.PlayerVars.EnableJsAPI = 1
		props.Events.OnReady = func(e *youtube.Event) {
			e.Target.PlayVideo()
		}
		// Create and cache the created player
		app.player = youtube.NewPlayer(playerID, props)
	})
}

Please feel free to contribute!

About

Gopherjs Bindings for Youtube's Iframe API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages