اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

قام بنشر (معدل)

السلام عليكم ورحمه الله وبركاته

عندى كود لتشغيل ملف صوتى wav

ولكنى أريد تحديد طول وقت الملف لاستخدامه فى أعمال أخرى

الكود هو:

كود:



Declare Function sndPlaySound32 Lib "winmm.dll" Alias _

"sndPlaySoundA" (ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long

Sub aa()

Path = "C:\Documents and Settings\Administrator\Desktop\app\alarm1.WAV"

Call sndPlaySound32(Path, 1)

End Sub

أرجو الاهتمام

تم تعديل بواسطه leprince2007
قام بنشر

أخي العزيز

أنشيئ وحدة نمطية جديدة وإنسخ اليها:


Option Compare Database

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Function GetMediaLength(FileName As String)

Dim MediaLength As Long

Dim RetString As String * 256

Dim CommandString As String

'open the media file

CommandString = "Open " & FileName & " alias MediaFile"

mciSendString CommandString, vbNullString, 0, 0&

'get the media file length

CommandString = "Set MediaFile time format milliseconds"

mciSendString CommandString, vbNullString, 0, 0&

CommandString = "Status MediaFile length"

mciSendString CommandString, RetString, Len(RetString), 0&

GetMediaLength = CLng(RetString)

'close the media file

CommandString = "Close MediaFile"

mciSendString CommandString, vbNullString, 0, 0&

End Function


وعند الحاجة إستدعي الوحدة النمطية كما يلي:

Dim Seconds, Minutes As Integer

Dim MilliSeconds As Long

' replace "E:\working.wav" with the path to your media file

MilliSeconds = GetMediaLength("E:\working.wav")

' the function GetMediaLength return the media length in milliseconds,

' so we will calculate the total minutes and seconds

Seconds = Int(MilliSeconds / 1000) Mod 60

Minutes = Int(MilliSeconds / 60000)

MilliSeconds = MilliSeconds Mod 1000

TotalTime = Minutes & ":" & Seconds & ":" & MilliSeconds

MsgBox (TotalTime)

جرّب ووافني بالنتيجة

والله من وراء القصد ... وهو حسبي

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information