2 // MediaControlWidget.fs
5 // Nicholas J. Little <arealityfarbetween@googlemail.com>
7 // Copyright (c) 2014 Nicholas J. Little
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 namespace Banshee.Dap.Bluetooth.Gui
28 open Banshee.Dap.Bluetooth.Wrappers
31 open Hyena.ThreadAssist
33 type MediaControlButton(img: Image, mc: INotifyMediaControl) as this =
34 inherit ToggleButton(Image = img)
37 let img = new Image(IconName = x)
38 let item = new MenuItem (Child = img)
40 let play = button_icon "media-playback-start"
41 let pause = button_icon "media-playback-pause"
42 let stop = button_icon "media-playback-stop"
43 let next = button_icon "media-skip-forward"
44 let prev = button_icon "media-skip-backward"
45 let fwd = button_icon "media-seek-forward"
46 let rwd = button_icon "media-seek-backward"
47 let vup = button_icon "audio-volume-high"
48 let vdn = button_icon "audio-volume-low"
49 let hidden _ = this.Active <- false
61 menu.Hidden.Add hidden
63 play.Activated.Add (fun o -> mc.Play ())
64 pause.Activated.Add (fun o -> mc.Pause ())
65 stop.Activated.Add (fun o -> mc.Stop ())
66 next.Activated.Add (fun o -> mc.Next ())
67 prev.Activated.Add (fun o -> mc.Previous ())
68 rwd.Activated.Add (fun o -> mc.Rewind ())
69 fwd.Activated.Add (fun o -> mc.FastForward ())
70 vup.Activated.Add (fun o -> mc.VolumeUp ())
71 vdn.Activated.Add (fun o -> mc.VolumeDown ())
72 override x.OnToggled () =
78 let img = new Image(IconName = "media-playback-start", IconSize = int IconSize.LargeToolbar)
79 new MediaControlButton (img, mc)