导航

« vb.net 获取文件短地址方法 C#获取Listview拖拽路径和文件名  »

VB.net播放mp3 方法 分享

VB.NET

 以下是vb.net中播放mp3的方法,整理了网上不少方法,挑出了一个相对实用简单的方法,大家可以尝试下。

声明部分:

    Declare Function FlashWindow Lib "user32" (ByVal hwnd As Integer, ByVal bInvert As Boolean) As Integer

    ' 宣告 API 

    Private Declare Function mciSendStringA Lib "winmm.dll" _

        (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _

        ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer

 

以下是

    Private Function PlayMidiFile(ByVal MusicFile As String) As Boolean

        If System.IO.File.Exists(MusicFile) Then

            mciSendStringA("stop music", "", 0, 0)

            mciSendStringA("close music", "", 0, 0)

            'mciSendStringA("open " & MusicFile & " alias music", "", 0, 0)

            mciSendStringA("open " & MusicFile & " alias music", "", 0, 0)

            PlayMidiFile = mciSendStringA("play music", "", 0, 0) = 0

        End If

        Return Nothing

    End Function

 

    Private Function StopMidi() As Boolean

        StopMidi = mciSendStringA("stop music", "", 0, 0) = 0

        mciSendStringA("close music", "", 0, 0)

    End Function

 

    Private Function PauseMidi() As Boolean

        Return mciSendStringA("pause music", "", 0, 0) = 0

    End Function

 

    Private Function ContinueMidi() As Boolean

        Return mciSendStringA("play music", "", 0, 0) = 0

    End Function

以下是调用方法:

 PlayMidiFile(ptShortPath) ' 播放 MP3 音樂

其中ptShortPath是mp3文件目录地址,注意这个地址中不能包含空格,否则不能正常播放,获取文件目录的短地址可以看以下这篇文章

vb.net 获取文件短地址方法

  • 顶一下





原创文章如转载,请注明:转载自落日故乡

本文链接地址:http://www.spersky.com/post/479.html

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

内容搜索


常用链接

最新评论及回复

Powered By Z-Blog

Copyright spersky All Rights Reserved.Theme Moonlight,Calf modified.