-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediaplayer.go
29 lines (25 loc) · 862 Bytes
/
mediaplayer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// +build windows
package main
import (
"fmt"
"log"
ole "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil"
)
func main() {
ole.CoInitialize(0)
unknown, err := oleutil.CreateObject("WMPlayer.OCX")
if err != nil {
log.Fatal(err)
}
wmp := unknown.MustQueryInterface(ole.IID_IDispatch)
collection := oleutil.MustGetProperty(wmp, "MediaCollection").ToIDispatch()
list := oleutil.MustCallMethod(collection, "getAll").ToIDispatch()
count := int(oleutil.MustGetProperty(list, "count").Val)
for i := 0; i < count; i++ {
item := oleutil.MustGetProperty(list, "item", i).ToIDispatch()
name := oleutil.MustGetProperty(item, "name").ToString()
sourceURL := oleutil.MustGetProperty(item, "sourceURL").ToString()
fmt.Println(name, sourceURL)
}
}