Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C++ program obtein volume in windows

using System.Runtime.InteropServices;
using UnityEngine;

public class VolumeManager : MonoBehaviour
{
    //The Unit to use when getting and setting the volume
    public enum VolumeUnit
    {
        //Perform volume action in decibels</param>
        Decibel,
        //Perform volume action in scalar
        Scalar
    }

    /// <summary>
    /// Gets the current volume
    /// </summary>
    /// <param name="vUnit">The unit to report the current volume in</param>
    [DllImport("ChangeVolumeWindows")]
    public static extern float GetSystemVolume(VolumeUnit vUnit);
    /// <summary>
    /// sets the current volume
    /// </summary>
    /// <param name="newVolume">The new volume to set</param>
    /// <param name="vUnit">The unit to set the current volume in</param>
    [DllImport("ChangeVolumeWindows")]
    public static extern void SetSystemVolume(double newVolume, VolumeUnit vUnit);

    // Use this for initialization
    void Start()
    {
        //Get volume in Decibel 
        float volumeDecibel = GetSystemVolume(VolumeUnit.Decibel);
        Debug.Log("Volume in Decibel: " + volumeDecibel);

        //Get volume in Scalar 
        float volumeScalar = GetSystemVolume(VolumeUnit.Scalar);
        Debug.Log("Volume in Scalar: " + volumeScalar);

        //Set volume in Decibel 
        SetSystemVolume(-16f, VolumeUnit.Decibel);

        //Set volume in Scalar 
        SetSystemVolume(0.70f, VolumeUnit.Scalar);
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: world space constant size 
Csharp :: search list for words c# 
Csharp :: difference between %e/E, %f/F and %g/G in program C 
Csharp :: unity generate random offset position around a gameobject 
Csharp :: Query mongodb collection as dynamic 
Csharp :: how to make physics in unity 
Csharp :: dictionary and generic class c# 
Csharp :: in clause db2 c# 
Csharp :: wpf change the content of the button wait 5 secound and then change it again 
Csharp :: querstring fromat asp.net c# 
Csharp :: c# 9.0 dynamic nedir 
Csharp :: C# Create Swiss QR-Bill API 
Csharp :: asp net route attribute vs httpget 
Csharp :: how to get odd saturday in a month in c# 
Csharp :: index was out of the bound array in c# 
Csharp :: c# list double min max 
Csharp :: edit pdf itextsharip 
Csharp :: unity sprite blurry when far 
Csharp :: notification platform not available c# 
Csharp :: print the top view of the binary tree 
Csharp :: ascii art american flag 
Csharp :: how to check if string from textbox exists in db 
Csharp :: unity how to have multiple headers 
Csharp :: c# compare 2 binary files 
Csharp :: c# date to julian YYJJJ date 
Csharp :: id dublication exception c# .net core 
Csharp :: character stay in ground unity 3d 
Csharp :: c# place all keys in dictionary into array 
Csharp :: unity timer 
Csharp :: All and Any linq c# examlpe replace 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =