From 63defcc7c7314dc4def19a9a05f893a29eb8fba5 Mon Sep 17 00:00:00 2001 From: jimmy Date: Wed, 20 Jul 2022 20:38:34 +1200 Subject: [PATCH] Remove go code --- slave/go.mod | 8 --- slave/go.sum | 4 -- slave/main.go | 147 -------------------------------------------------- 3 files changed, 159 deletions(-) delete mode 100644 slave/go.mod delete mode 100644 slave/go.sum delete mode 100644 slave/main.go diff --git a/slave/go.mod b/slave/go.mod deleted file mode 100644 index 3c6d7b1..0000000 --- a/slave/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module slave - -go 1.18 - -require ( - github.com/adrg/libvlc-go/v3 v3.1.5 - github.com/gotk3/gotk3 v0.6.1 -) diff --git a/slave/go.sum b/slave/go.sum deleted file mode 100644 index f94ffbd..0000000 --- a/slave/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -github.com/adrg/libvlc-go/v3 v3.1.5 h1:TGO0dvubmLCSE4ocOtJYMBlPYALm8aGMkCuDZ6cXnM0= -github.com/adrg/libvlc-go/v3 v3.1.5/go.mod h1:xJK0YD8cyMDejnrTFQinStE6RYCV1nlfS8KmqTpszSc= -github.com/gotk3/gotk3 v0.6.1 h1:GJ400a0ecEEWrzjBvzBzH+pB/esEMIGdB9zPSmBdoeo= -github.com/gotk3/gotk3 v0.6.1/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= diff --git a/slave/main.go b/slave/main.go deleted file mode 100644 index ae95abd..0000000 --- a/slave/main.go +++ /dev/null @@ -1,147 +0,0 @@ -package main - -import ( - "log" - "os" - - vlc "github.com/adrg/libvlc-go/v3" - "github.com/gotk3/gotk3/cairo" - "github.com/gotk3/gotk3/glib" - "github.com/gotk3/gotk3/gtk" -) - -const appID = "com.github.libvlc-go.gtk3-media-player-example" - -func builderGetObject(builder *gtk.Builder, name string) glib.IObject { - obj, _ := builder.GetObject(name) - return obj -} - -func assertErr(err error) { - if err != nil { - log.Panic(err) - } -} - -func assertConv(ok bool) { - if !ok { - log.Panic("invalid widget conversion") - } -} - -func playerReleaseMedia(player *vlc.Player) { - player.Stop() - if media, _ := player.Media(); media != nil { - media.Release() - } -} - -func main() { - // Initialize libVLC module. - err := vlc.Init("--quiet", "--no-xlib") - assertErr(err) - - // Create a new player. - player, err := vlc.NewPlayer() - assertErr(err) - - // Create new GTK application. - app, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE) - assertErr(err) - - app.Connect("activate", func() { - // Load application layout. - builder, err := gtk.BuilderNewFromFile("layout.glade") - assertErr(err) - - // Get application window. - appWin, ok := builderGetObject(builder, "appWindow").(*gtk.ApplicationWindow) - assertConv(ok) - - // Get play button. - playButton, ok := builderGetObject(builder, "playButton").(*gtk.Button) - assertConv(ok) - - // Add builder signal handlers. - signals := map[string]interface{}{ - "onRealizePlayerArea": func(playerArea *gtk.DrawingArea) { - // Set window for the player. - playerWindow, err := playerArea.GetWindow() - assertErr(err) - err = setPlayerWindow(player, playerWindow) - assertErr(err) - }, - "onDrawPlayerArea": func(playerArea *gtk.DrawingArea, cr *cairo.Context) { - cr.SetSourceRGB(0, 0, 0) - cr.Paint() - }, - "onActivateOpenFile": func() { - fileDialog, err := gtk.FileChooserDialogNewWith2Buttons( - "Choose file...", - appWin, gtk.FILE_CHOOSER_ACTION_OPEN, - "Cancel", gtk.RESPONSE_DELETE_EVENT, - "Open", gtk.RESPONSE_ACCEPT) - assertErr(err) - defer fileDialog.Destroy() - - fileFilter, err := gtk.FileFilterNew() - assertErr(err) - fileFilter.SetName("Media files") - fileFilter.AddPattern("*.mp4") - fileFilter.AddPattern("*.mp3") - fileDialog.AddFilter(fileFilter) - - if result := fileDialog.Run(); result == gtk.RESPONSE_ACCEPT { - // Release current media, if any. - playerReleaseMedia(player) - - // Get selected filename. - filename := fileDialog.GetFilename() - - // Load media and start playback. - if _, err := player.LoadMediaFromPath(filename); err != nil { - log.Printf("Cannot load selected media: %s\n", err) - return - } - - player.Play() - playButton.SetLabel("gtk-media-pause") - } - }, - "onActivateQuit": func() { - app.Quit() - }, - "onClickPlayButton": func(playButton *gtk.Button) { - if media, _ := player.Media(); media == nil { - return - } - - if player.IsPlaying() { - player.SetPause(true) - playButton.SetLabel("gtk-media-play") - } else { - player.Play() - playButton.SetLabel("gtk-media-pause") - } - }, - "onClickStopButton": func(stopButton *gtk.Button) { - player.Stop() - playButton.SetLabel("gtk-media-play") - }, - } - builder.ConnectSignals(signals) - - appWin.ShowAll() - app.AddWindow(appWin) - }) - - // Cleanup on exit. - app.Connect("shutdown", func() { - playerReleaseMedia(player) - player.Release() - vlc.Release() - }) - - // Launch the application. - os.Exit(app.Run(os.Args)) -} \ No newline at end of file