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

أريد كود لمعرفة طول ملف (وقت) wav


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

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

عندى كود لتشغيل ملف صوتى 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)

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

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

رابط هذا التعليق
شارك

شكرا أخى على اهتمامك الكبير

أخى الكود يعطينى خطأ فى هذا السطر

[size=5][b]GetMediaLength = CLng(RetString)[/b][/size]

هل من الممكن أن ترفق لى ملف بالحل

وشكرا جزيلاً

رابط هذا التعليق
شارك

من فضلك سجل دخول لتتمكن من التعليق

ستتمكن من اضافه تعليقات بعد التسجيل



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

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

Important Information