github.com/go-ole/go-ole@v1.2.6/_example/mediaplayer/mediaplayer.go (about) 1 // +build windows 2 3 package main 4 5 import ( 6 "fmt" 7 "log" 8 9 ole "github.com/go-ole/go-ole" 10 "github.com/go-ole/go-ole/oleutil" 11 ) 12 13 func main() { 14 ole.CoInitialize(0) 15 unknown, err := oleutil.CreateObject("WMPlayer.OCX") 16 if err != nil { 17 log.Fatal(err) 18 } 19 wmp := unknown.MustQueryInterface(ole.IID_IDispatch) 20 collection := oleutil.MustGetProperty(wmp, "MediaCollection").ToIDispatch() 21 list := oleutil.MustCallMethod(collection, "getAll").ToIDispatch() 22 count := int(oleutil.MustGetProperty(list, "count").Val) 23 for i := 0; i < count; i++ { 24 item := oleutil.MustGetProperty(list, "item", i).ToIDispatch() 25 name := oleutil.MustGetProperty(item, "name").ToString() 26 sourceURL := oleutil.MustGetProperty(item, "sourceURL").ToString() 27 fmt.Println(name, sourceURL) 28 } 29 }