示例#1
0
        /// <summary>
        /// Fetches the contents of Content\Index.html and formats it using dummy values when requests to DummyIndex.
        /// This allows testing of the module without affecting volume or any audio devices.
        /// </summary>
        /// <returns>Content\Index.html with dummy values.</returns>
        public Negotiator DummyIndex()
        {
            AudioDeviceList devices = new AudioDeviceList
            {
                new AudioDevice
                {
                    Id = "1",
                    IsCurrentDevice = true,
                    Name            = "Speaker"
                },
                new AudioDevice
                {
                    Id = "2",
                    IsCurrentDevice = false,
                    Name            = "Headphones"
                },
                new AudioDevice
                {
                    Id = "3",
                    IsCurrentDevice = false,
                    Name            = "Monitor"
                }
            };

            string  file  = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\ng-knob-options.json"));
            dynamic model = new IndexModel
            {
                Volume      = "75",
                Devices     = $"[{string.Join(",", devices.Select(MakeJavaScriptObjectString))}]",
                KnobOptions = $"{JsonToJavaScriptObject(file)}"
            };

            return(View["Index", model]);
        }
        public void TestGetDummyPlaybackDevices()
        {
            Browser         browser = new Browser(with => with.Module(new HttpModule()));
            BrowserResponse result  = browser.Get("/DummyPlaybackDevices", with =>
            {
                with.AjaxRequest();
                with.Header("Accept", "application/json");
            });

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            string json = result.Body.AsString();

            Assert.IsFalse(string.IsNullOrWhiteSpace(json));

            AudioDeviceList data = JsonConvert.DeserializeObject <AudioDeviceList>(json);

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Count == 3);

            string[] deviceNames = { "Speaker", "Headphones", "Monitor" };

            data.ForEach((d, i) =>
            {
                Assert.IsTrue(d.Id == (i + 1).ToString());
                Assert.IsTrue(i > 0 || d.IsCurrentDevice);
                Assert.IsTrue(d.Name == deviceNames[i]);
            });
        }
示例#3
0
        public override void Execute()
        {
            var obsAudioDevices = AudioService.GetAudioOutputDevices();

            var audioDeviceList = new AudioDeviceList();

            obsAudioDevices.ForEach(x => audioDeviceList.Add(x));

            EmitService.EmitAudioOutputDevices(audioDeviceList);
        }
示例#4
0
        /// <summary>
        /// Fetches the contents of Content\Index.html and formats it using the current volume and available audio devices
        /// found on the host machine using classes and methods defined in the referenced Audio library.
        /// </summary>
        /// <returns>Content\Index.html with live values.</returns>
        public Negotiator Index()
        {
            if (_AuthenticateUser)
            {
                this.RequiresAuthentication();
            }

            float           volume  = GetCurrentVolume();
            AudioDeviceList devices = GetAudioDeviceList();
            string          file    = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\ng-knob-options.json"));
            dynamic         model   = new IndexModel
            {
                Volume      = volume.ToString(),
                Devices     = $"[{string.Join(",", devices.Select(MakeJavaScriptObjectString))}]",
                KnobOptions = $"{JsonToJavaScriptObject(file)}"
            };

            return(View["Index", model]);
        }
示例#5
0
 /// <summary>
 ///     Gets a list of audio output devices for a given audio output module.
 /// </summary>
 /// <param name="audioOutput"></param>
 /// <returns></returns>
 public AudioDeviceList GetAudioDeviceList(AudioOutput audioOutput)
 {
     var handle = InteropHelper.StringToPtr(audioOutput.Name);
     var result =
         new AudioDeviceList(_getAudioDeviceListFunction.Delegate(VlcInstance.InstancePointer,
             handle.AddrOfPinnedObject()));
     handle.Free();
     return result;
 }
 /// <summary>
 /// Emits the list of all available audio output devices.
 /// </summary>
 /// <param name="audioDeviceList"></param>
 public static void EmitAudioOutputDevices(AudioDeviceList audioDeviceList)
 {
     EmitSerializedOutput(AvailableCommand.GetAudioOutputDevices, audioDeviceList);
 }