必须先感叹一句,GO语言太强了,自带的库很丰富,语法够简洁,即使没接触过GO,稍微学习一下就能用几十行代码做出个简单的web服务器。由于foobar2000可以通过命令行进行操作,比如:foobar2000.exe /command:Next就是切换到下一曲。利用这个特性,就能很轻易的实现远程操控foobar2000。下面是GO语言的代码,文件名为foobar2k_web.go:package main
import (
"os/exec"
"fmt"
"io"
"net/http"
"os"
)
var service_port = ":9527"
var service_path = "/foobar2k"
var foobar2k_path = "d:\\bin\\foobar2000\\foobar2000.exe"
var fbcmd_map = map[string]string{"prev":"Previous","next":"Next","vdown":"Down","vup":"Up","playpause":"Play or pause"}
func FB2KServer(w http.ResponseWriter, req *http.Request) {
io.WriteString(w
...
继续阅读
(7)