Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Media player in active X

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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 449
Default Media player in active X

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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Media player in active X


"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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Media player in active X


"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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Media player in active X


"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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 449
Default Media player in active X

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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Media player in active X


"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
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
Controlling media player in VBA question teepee Excel Discussion (Misc queries) 3 April 14th 07 04:56 PM
Close Windows Media Player Cordell Excel Discussion (Misc queries) 1 January 30th 07 04:43 AM
Force asx to bring up Windows Media Player - How? chaser7016 Excel Discussion (Misc queries) 1 January 23rd 07 01:09 PM
Media player import to excel David Excel Discussion (Misc queries) 0 September 14th 06 01:39 AM
Media Player versus Windows Media Player teepee Excel Discussion (Misc queries) 1 October 14th 05 02:25 AM


All times are GMT +1. The time now is 04:43 PM.

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

About Us

"It's about Microsoft Excel"