By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,581 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,581 IT Pros & Developers. It's quick & easy.

How to Play Audio File using Media Player OCX without Buffering?

nicebasic
P: 91
I have written a small French-English Dictionary using VB.

I have come to a serious problem which is new to me. Maybe I didn't notice this problem before, but it's a bad bug in my program.

I record an audio file for a French word in my dictionary and another audio file for an English word in the same dictionary.

When the user picks a word from the listbox, if the selected item has an audio file, two icons appear: one for the French pronunciation and another for the English pronunciation.

Up to now, everything seems to be OK. I use "msdxm.ocx" to embed Media Player into my application. It's fast and easy. I like it. Sometimes I use "wmp.dll" to embed Windows Media Player in my projects. But I like the first one better.

The problem is that when you press the Play/Pronounce Button many times before the current audio file ends, the audio file starts not from the very beginning. It seems that about 1 or 2 seconds of the start of the audio file is lost and not played.

I guess that it might be related to "BufferingTime" which is a ReadOnly Property for MediaPlayer and by default, it's equal to 5.

Imagine that we have an audio file. If we add a Media Player object in our project, and a Button calls that Media Player with that audio file, you can easily play audio materials. But, if you press that Button many times, sometimes it isn't played from the very beginning.

This is such a bad bug especially for very short audio files. In my case, I have a very short audio file that pronounces just one word. Sometimes it's about 1 second long or even shorter.

How can I solve this problem?

Thank you very much.
Dec 27 '10 #1
Share this Question
Share on Google+
4 Replies


P: 4
may you use mmcontrol to play sound
http://www.ehow.com/how_7533590_use-...ual-basic.html
Aug 31 '11 #2

nicebasic
P: 91
Thank you for your reply.

Unfortunately, MMControl does not support SelectionStart and SelectionEnd properties.

I put the audio data in one file and choose which part should be played based on the selected word.

So, MMControl does not seem to be suitable for this purpose.

Thank you again for your attention.
Aug 31 '11 #3

Guido Geurs
Expert 100+
P: 767
Why not placing each pronunciation in a separate file? and place in a hidden list the name of each file like:

word1, word1_E.mp3, word1_F.mp3
word2, word2_E.mp3, word2_F.mp3
...

show word1 in the dropdownlist and open word1_E.mp3 for English pronunciation and word1_F.mp3 for French.

I think it's better to maintain when each word is in a different file !

PS:
I have used MMcontrol in a program for reading books on CD (for persons with a visual handicap).
To start from the last read page I use the time setting to start from a certain position like:

Expand|Select|Wrap|Line Numbers
  1.    Set FileSYS = CreateObject("Scripting.FileSystemObject")
  2.    If FileSYS.FileExists(GEBRUIK_FILE) Then
  3.       With MMControl
  4.          .TimeFormat = 1
  5.          .Command = "Stop"
  6.          .Command = "Close"
  7.          .FileName = GEBRUIK_FILE
  8.          .Command = "Open"
  9.          .From = Val(VANAF_BLADZIJDE)
  10.          .Command = "Play"
  11.       End With
.From is the start time as long in timeformat= hh.mm.ss
.To is the Stop time (not used in my program)
But I think it will be difficult when the words pronunciation will be in one file and You have to define the start and end time in the file !!
Sep 2 '11 #4

nicebasic
P: 91
Dear Guido Geurs,

I have to admit that you're a real genius. You replied one of my questions about updating the Form Caption in a Minimized Form. Your solution was really great and helped me solve the problem.

I'm happy you have focused on this post. It's rather difficult to work with MMControl, but it's faster and easier for playing separate audio files.

I'll give your solution a try. But I have to write a sample code to test .From and .To properties.

Again I say that you're really talented.

Thank you so much.
Sep 2 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.