Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]()
Quick question if I may...
I need to play two simultaneous sound files in Excel, and as I cannot have two userforms at the same time, I'm trying to have one play as a userform in mediaplayer and the other play as a windos media player ActiveX object embedded into the sheet (using Office 2007). However when I try to instruct the windows media player to begin playing it's file it hits a bug and refuses to budge. Am I attempting the impossible or just missing the obvious? Many thanks Private Sub UserForm_Activate() Dim Mfile As String Mfile = "c:\video\crowd.wav" MP.Open (Mfile) WindowsMediaPlayer1.URL = "c:\video\crowdup.wav" |
#2
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]()
Put two mediaplayers onto the userform.
HTH. Best wishes Harald "teepee" wrote in message ... Quick question if I may... I need to play two simultaneous sound files in Excel, and as I cannot have two userforms at the same time, I'm trying to have one play as a userform in mediaplayer and the other play as a windos media player ActiveX object embedded into the sheet (using Office 2007). However when I try to instruct the windows media player to begin playing it's file it hits a bug and refuses to budge. Am I attempting the impossible or just missing the obvious? Many thanks Private Sub UserForm_Activate() Dim Mfile As String Mfile = "c:\video\crowd.wav" MP.Open (Mfile) WindowsMediaPlayer1.URL = "c:\video\crowdup.wav" |
#3
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]() "Harald Staff" wrote in message ... Put two mediaplayers onto the userform. Never knew you could do that! Obvious when you don't make stupid assumptions. Many thanks |
#4
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]() "Harald Staff" wrote in message ... Put two mediaplayers onto the userform. I knew it couldn't be that simple. They won't play simultaneously |
#5
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]() "teepee" wrote in message ... "Harald Staff" wrote in message ... Put two mediaplayers onto the userform. I knew it couldn't be that simple. They won't play simultaneously but maybe a media player and a windows media player 8-) |
#6
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]()
I have no problems with two windowsmediaplayers on a userform. Add also a
togglebutton1 and change path to soundfiles: Private Sub UserForm_Initialize() Me.WindowsMediaPlayer1.URL = _ "C:\Users\Harald\Music\adrian belew - bird in a box (remix).mp3" Me.WindowsMediaPlayer2.URL = _ "C:\Users\Harald\Music\adrian belew - man in the moon.mp3" End Sub Private Sub ToggleButton1_Click() If Me.ToggleButton1.Value = True Then Me.WindowsMediaPlayer1.Controls.Play Me.WindowsMediaPlayer2.Controls.Play Else Me.WindowsMediaPlayer1.Controls.pause Me.WindowsMediaPlayer2.Controls.pause End If End Sub HTH. Best wishes Harald |
#7
![]()
Posted to microsoft.public.excel,microsoft.public.excel.misc
|
|||
|
|||
![]() "Harald Staff" wrote in message ... I have no problems with two windowsmediaplayers on a userform. Add also a togglebutton1 and change path to soundfiles: Yes it works OK with two wmp but not with two mp. But funnily enough I find a media player and a windows media player in the userform keep better sync with each other than two windows media players - especially when the files loop Here is my code for keeping them more or less in sync - cell a1 will show the media player current position and a2 will show the wmp current poistion. If you make cell a3 = a1-a2 then it will work. Any improvements welcomed - if anyone can find a way to put them completely in sync that would be a dream... Private Sub UserForm_Activate() WindowsMediaPlayer1.settings.setMode "loop", True WindowsMediaPlayer1.URL = "c:\video\file1.wav" MP.PlayCount = 1000 Dim Mfile As String Mfile = "c:\video\file2.wav" MP.Open (Mfile) Do DoEvents Dim Oldpos As Long 'Dim oldpos2 As Long If MP.currentPosition = Oldpos + 0.1 Then 'after plus sign number of seconds _ between uppdate of cell A1 Application.Cells(1, 1) = MP.currentPosition Application.Cells(1, 2) = WindowsMediaPlayer1.Controls.currentPosition On Error Resume Next Oldpos = Application.WorksheetFunction.RoundDown(MP.current Position, 0) Calculate UserForm4.Repaint Else End If If MP.currentPosition < Oldpos Then 'this should trigger whenever the audio file loops Application.Cells(1, 1) = MP.currentPosition WindowsMediaPlayer1.Controls.currentPosition = MP.currentPosition - Range("a3") 'a3 is a subtraction of the current position of the media player and the windows media player - so they should be brought into sync, although in practice it's sometimes up to a third of a second out Oldpos = Application.WorksheetFunction.RoundDown(MP.current Position, 0) Calculate UserForm4.Repaint Else End If If MP.PlayState = mpStopped Then Exit Do If MP.PlayState = mpClosed Then Exit Do If MP.PlayState = mpPaused Then Exit Do Loop Until MP.currentPosition = 10 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Controlling media player in VBA question | Excel Discussion (Misc queries) | |||
Close Windows Media Player | Excel Discussion (Misc queries) | |||
Force asx to bring up Windows Media Player - How? | Excel Discussion (Misc queries) | |||
Media player import to excel | Excel Discussion (Misc queries) | |||
Media Player versus Windows Media Player | Excel Discussion (Misc queries) |