减少除我自己的应用程序之外的所有音量

时间:2014-07-12 21:40:34

标签: vb.net audio volume

我想知道是否可以在VB.NET上模拟iPhone通知声音,从它们的处理方式来看。

例如,如果您在iPhone上收到短信,在听音乐时,音乐音量会在播放提示时降低至约25%,然后音量会恢复。

这可以用vb.net完成吗?

我已经看到了降低系统音量的方法,但是这不会减少我应用的音量吗?

我发现这个效果很好,但我想知道我是否可以将我的应用与此分开

Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Namespace WindowsFormsApplication1
    Partial Public Class Form1
        Inherits Form
        Private Const APPCOMMAND_VOLUME_MUTE As Integer = &H80000
        Private Const APPCOMMAND_VOLUME_UP As Integer = &HA0000
        Private Const APPCOMMAND_VOLUME_DOWN As Integer = &H90000
        Private Const WM_APPCOMMAND As Integer = &H319

        <DllImport("user32.dll")> _
        Public Shared Function SendMessageW(ByVal hWnd As IntPtr, _
               ByVal Msg As Integer, ByVal wParam As IntPtr, _
               ByVal lParam As IntPtr) As IntPtr
        End Function

        Private Sub btnMute_Click(ByVal sender As Object, ByVal e As EventArgs)
            SendMessageW(Me.Handle, WM_APPCOMMAND, _
                          Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE))
        End Sub

        Private Sub btnDecVol_Click(ByVal sender As Object, ByVal e As EventArgs)
            SendMessageW(Me.Handle, WM_APPCOMMAND, _
                         Me.Handle, New IntPtr(APPCOMMAND_VOLUME_DOWN))
        End Sub

        Private Sub btnIncVol_Click(ByVal sender As Object, ByVal e As EventArgs)
            SendMessageW(Me.Handle, WM_APPCOMMAND, _
                         Me.Handle, New IntPtr(APPCOMMAND_VOLUME_UP))
        End Sub
    End Class
End Namespace

0 个答案:

没有答案