diff --git a/.gitignore b/.gitignore index 728f639..66a6d24 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ toolchains/ /src/google.golang.org/ /toolchain/ /test/ +/server/web/pages/template/pages/msx diff --git a/gen_web.go b/gen_web.go index 76dc4f1..e3e009f 100644 --- a/gen_web.go +++ b/gen_web.go @@ -28,6 +28,7 @@ func main() { run("rm", "-rf", srcGo+"template/pages") run("cp", "-r", compileHtml, srcGo+"template/pages") + run("cp", "-r", "server/web/msx/pages", srcGo+"template/pages/msx") files := make([]string, 0) diff --git a/server/web/msx/msx.go b/server/web/msx/msx.go index 3891d73..21ad186 100644 --- a/server/web/msx/msx.go +++ b/server/web/msx/msx.go @@ -29,13 +29,24 @@ type msxMenuItem struct { Data msxData `json:"data,omitempty"` } +type msxTemplate struct { + Type string `json:"type,omitempty"` + Layout string `json:"layout,omitempty"` + Color string `json:"color,omitempty"` + Icon string `json:"icon,omitempty"` + IconSize string `json:"iconSize,omitempty"` + BadgeColor string `json:"badgeColor,omitempty"` + TagColor string `json:"tagColor,omitempty"` + Properties gin.H `json:"properties,omitempty"` +} + type msxData struct { - Type string `json:"type,omitempty"` - Headline string `json:"headline,omitempty"` - Action string `json:"action,omitempty"` - Template gin.H `json:"template,omitempty"` - Items []msxItem `json:"items,omitempty"` - Pages []msxPage `json:"pages,omitempty"` + Type string `json:"type,omitempty"` + Headline string `json:"headline,omitempty"` + Action string `json:"action,omitempty"` + Template msxTemplate `json:"template,omitempty"` + Items []msxItem `json:"items,omitempty"` + Pages []msxPage `json:"pages,omitempty"` } type msxItem struct { @@ -47,6 +58,7 @@ type msxItem struct { Icon string `json:"icon,omitempty"` Badge string `json:"badge,omitempty"` Tag string `json:"tag,omitempty"` + Data gin.H `json:"data,omitempty"` } type msxPage struct { @@ -73,7 +85,8 @@ func msxTorrents(c *gin.Context) { item := msxItem{ Title: tor.Title, Image: tor.Poster, - Action: "content:" + host + "/msx/playlist/" + url.PathEscape(tor.Title) + "?hash=" + tor.TorrentSpec.InfoHash.HexString(), + Action: "content:" + host + "/msx/playlist/" + url.PathEscape(tor.Title) + + "?hash=" + tor.TorrentSpec.InfoHash.HexString() + "&platform={PLATFORM}", } list[i] = item } @@ -90,11 +103,11 @@ func msxTorrents(c *gin.Context) { Label: "Torrents", Data: msxData{ Type: "pages", - Template: gin.H{ - "type": "separate", - "layout": "0,0,2,4", - "icon": "msx-white-soft:movie", - "color": "msx-glass", + Template: msxTemplate{ + Type: "separate", + Layout: "0,0,2,4", + Icon: "msx-white-soft:movie", + Color: "msx-glass", }, Items: list, }, @@ -134,6 +147,7 @@ func msxPlaylist(c *gin.Context) { }) return } + platform, _ := c.GetQuery("platform") tor := torr.GetTorrent(hash) if tor == nil { @@ -166,11 +180,27 @@ func msxPlaylist(c *gin.Context) { continue } name := filepath.Base(f.Path) + uri := host + "/stream/" + url.PathEscape(name) + "?link=" + hash + "&index=" + fmt.Sprint(f.Id) + "&play" item := msxItem{ Label: name, PlayerLabel: strings.TrimSuffix(name, filepath.Ext(name)), - Action: action + ":" + host + "/stream/" + url.PathEscape(name) + "?link=" + hash + "&index=" + fmt.Sprint(f.Id) + "&play", + Action: action + ":" + uri, } + + if (platform == "android" || platform == "firetv") { + item.Action = "system:tvx:launch" + item.Data = gin.H{ + "id": hash + "-" + fmt.Sprint(f.Id), + "uri": uri, + "type": mime, + } + } else if (platform == "lg") { + item.Action = "content:request:interaction:init@" + host + "/msx/webos.html?url=" + url.QueryEscape(uri) + } else if (platform == "ios" || platform == "mac") { + // TODO - for iOS and Mac the application must be defined in scheme but we don't know what user has installed + // item.Action = "system:tvx:launch:vlc://"+uri + } + if isViewed(viewed, f.Id) { item.Tag = " " } @@ -190,18 +220,30 @@ func msxPlaylist(c *gin.Context) { res := msxData{ Headline: tor.Title, Type: "list", - Template: gin.H{ - "type": "control", - "layout": "0,2,12,1", - "color": "msx-glass", - "icon": "msx-white-soft:movie", - "iconSize": "medium", - "badgeColor": "msx-yellow", - "tagColor": "msx-yellow", + Template: msxTemplate{ + Type: "control", + Layout: "0,2,12,1", + Color: "msx-glass", + Icon: "msx-white-soft:movie", + IconSize: "medium", + BadgeColor: "msx-yellow", + TagColor: "msx-yellow", }, Items: list, } + if (platform == "tizen") { + res.Template.Properties = gin.H{ + "button:content:icon": "tune", + "button:content:action": "content:request:interaction:init@" + host + "/msx/tizen.html", + } + } else if (platform == "netcast") { + res.Template.Properties = gin.H{ + "button:content:icon": "tune", + "button:content:action": "system:netcast:menu", + } + } + // If only one item start to play immediately but it not works // if (len(list) == 1) { // res.Action = "execute:" + list[0].Action diff --git a/server/web/msx/pages/tizen.html b/server/web/msx/pages/tizen.html new file mode 100644 index 0000000..d4b31cc --- /dev/null +++ b/server/web/msx/pages/tizen.html @@ -0,0 +1,14 @@ + + +
+