Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default playing mp3 files on user input

I have few .mp3 files in C:\MP3 folder
a.mp3
b.mp3
c.mp3
..
..
..
z.mp3

These files are of duration 10 seconds

In an excel file, I want a text box that should allow two characters.

The moment I open the excel file, it should take the cursor in that
textbox automatically.

If I type "A" in the textbox, it should play a.mp3 file without opening
the mp3 player. (I am using musicmatch/windows media player mp3 player)

If I type "B" as the second character in the textbox, it should erase
"A" which was entered earlier, show the character "B" in the text box
and play b.mp3 file.

If b.mp3 is playing and before the song is over (before 10 seconds) if
I enter C as the second character in the textbox, it should stop b.mp3
song and start plaing c.mp3

If I type any other character or if I press any other key besides A-Z,
it should stop the current song and should not play anything, it should
just erase value in the text box and place the cursor there and wait
for an A-Z input.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default playing mp3 files on user input


Studying a language and excersising alphabet pronunciation..?
I don't think VBA can do this without using a self-made or downloaded
ActiveX control.





"Maxi" schreef in bericht
oups.com...
I have few .mp3 files in C:\MP3 folder
a.mp3
b.mp3
c.mp3
.
.
.
z.mp3

These files are of duration 10 seconds

In an excel file, I want a text box that should allow two characters.

The moment I open the excel file, it should take the cursor in that
textbox automatically.

If I type "A" in the textbox, it should play a.mp3 file without opening
the mp3 player. (I am using musicmatch/windows media player mp3 player)

If I type "B" as the second character in the textbox, it should erase
"A" which was entered earlier, show the character "B" in the text box
and play b.mp3 file.

If b.mp3 is playing and before the song is over (before 10 seconds) if
I enter C as the second character in the textbox, it should stop b.mp3
song and start plaing c.mp3

If I type any other character or if I press any other key besides A-Z,
it should stop the current song and should not play anything, it should
just erase value in the text box and place the cursor there and wait
for an A-Z input.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default playing mp3 files on user input

Answered to soon...
Playing an MP3 without showing Mediaplayer seems not too hard.

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal _
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
_
ByVal nShowCmd As Long) As Long

Private Sub wsBtnMP3_Click()

ShellExecute vbNull, "Open", "C:\a.mp3", vbNullString, "C:\", 0

End Sub




"moon" schreef in bericht
. ..

Studying a language and excersising alphabet pronunciation..?
I don't think VBA can do this without using a self-made or downloaded
ActiveX control.





"Maxi" schreef in bericht
oups.com...
I have few .mp3 files in C:\MP3 folder
a.mp3
b.mp3
c.mp3
.
.
.
z.mp3

These files are of duration 10 seconds

In an excel file, I want a text box that should allow two characters.

The moment I open the excel file, it should take the cursor in that
textbox automatically.

If I type "A" in the textbox, it should play a.mp3 file without opening
the mp3 player. (I am using musicmatch/windows media player mp3 player)

If I type "B" as the second character in the textbox, it should erase
"A" which was entered earlier, show the character "B" in the text box
and play b.mp3 file.

If b.mp3 is playing and before the song is over (before 10 seconds) if
I enter C as the second character in the textbox, it should stop b.mp3
song and start plaing c.mp3

If I type any other character or if I press any other key besides A-Z,
it should stop the current song and should not play anything, it should
just erase value in the text box and place the cursor there and wait
for an A-Z input.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default playing mp3 files on user input

Hi Maxi,

In ThisWorkbook module:
Private Sub Workbook_Open()
ActiveSheet.OLEObjects("TextBox1").Object.MaxLengt h = 2
ActiveSheet.OLEObjects("TextBox1").Object.Value = ""
ActiveSheet.OLEObjects("TextBox1").Activate
End Sub

In Sheet module:
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String _
, ByVal lpstrReturnString As String, ByVal uReturnLength As Long _
, ByVal hwndCallback As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String _
, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Private Playing As Boolean, Current As String

Private Sub PlaySong(Play As Boolean, FullPathSong$, Optional Reprise& = 0)
On Error Resume Next
Call mciSendString("Stop MPFE", 0&, 0, 0)
Call mciSendString("Close MPFE", 0&, 0, 0)
If Not Play Then Exit Sub
Dim Song As String
Song = FullPathSong
If Dir(Song) = "" Then Exit Sub
Song = GetShortPath(Song)
Call mciSendString("Open " & Song & " Alias MPFE", 0&, 0, 0)
Call mciSendString("play MPFE from " & Reprise, 0&, 0, 0)
End Sub

Private Function GetShortPath(strFileName As String) As String
Dim lngRes As Long, strPath As String
strPath = String(165, 0)
lngRes = GetShortPathName(strFileName, strPath, 164)
GetShortPath = Left(strPath, lngRes)
End Function

Private Sub TextBox1_Change()
If TextBox1.Text = "" Then GoTo 1
If Len(TextBox1.Text) 1 Then TextBox1.Text = Right$(TextBox1.Text, 1)
Const DefaultPath$ = "C:\MP3\"
If Dir(DefaultPath & TextBox1.Text & ".mp3") = "" Then
1: If Playing Then Playing = False Else Exit Sub
Else
Playing = True
Current = DefaultPath & TextBox1.Text & ".mp3"
End If
Call PlaySong(Playing, Current)
End Sub

MP

"Maxi" a écrit dans le message de news:
...
I have few .mp3 files in C:\MP3 folder
a.mp3
b.mp3
c.mp3
.
.
.
z.mp3

These files are of duration 10 seconds

In an excel file, I want a text box that should allow two characters.

The moment I open the excel file, it should take the cursor in that
textbox automatically.

If I type "A" in the textbox, it should play a.mp3 file without opening
the mp3 player. (I am using musicmatch/windows media player mp3 player)

If I type "B" as the second character in the textbox, it should erase
"A" which was entered earlier, show the character "B" in the text box
and play b.mp3 file.

If b.mp3 is playing and before the song is over (before 10 seconds) if
I enter C as the second character in the textbox, it should stop b.mp3
song and start plaing c.mp3

If I type any other character or if I press any other key besides A-Z,
it should stop the current song and should not play anything, it should
just erase value in the text box and place the cursor there and wait
for an A-Z input.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default playing mp3 files on user input

Thanks Michael, it is awesome. However, there is a small problem.

The entire code works fine but when the song is playing, it gives me a
lot of hissing sound. When I play the file in Windows Media Player or
Musicmatch seperately it plays fine. It gives hissing sound only if I
play through this file.

Here is a link to download sample a.mp3, b.mp3 and c.mp3 file.
http://www40.brinkster.com/maxlott/mp3.htm

Any ideas??

Michel Pierron wrote:
Hi Maxi,

In ThisWorkbook module:


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting the actual playing or NOT playing of a WAV file Bajbaj Excel Discussion (Misc queries) 0 October 24th 07 09:16 PM
Can I user input to seek out particular files and copy/move them? silkworm Excel Programming 2 January 20th 06 07:28 PM
User Input to open multiple files Mike D.[_2_] Excel Programming 2 November 16th 04 09:32 AM
Playing .wav files (why do a few cause warning messages?) Cybert Excel Programming 0 October 19th 04 09:38 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 01:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"