Solved

Help Me Please (multimedia sort of)

Posted on 1998-08-04
15
177 Views
Last Modified: 2010-05-03
Okay.  I have this program that can play a Midi file (.mid).  and I have a scroll bar that shows the position of the midi while it is playing.  I want the user to be able to click on the scroll bar (the little box) and move it  and when they let go then the midi is in the position of where the scroll bar is.  I am using the Microsoft Multimedia Control.  Please help me
0
Comment
Question by:aquakid
  • 7
  • 4
  • 4
15 Comments
 

Author Comment

by:aquakid
Comment Utility
Adjusted points to 100
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
Are you using MMControl, or API?
0
 

Expert Comment

by:woodworker
Comment Utility
Set the timeformat property of the media control to one that you are comfortable using such as milliseconds. Set the min and max properties of your scrollbar based on the media control length property.  in your change event for the scroll bar figure the position you want to move to in the media control based on the value of the scroll bar. Use the Command property of the media control to "Seek" the position you want.

  MMControl1.Notify = False
  MMControl1.Wait = True
  MMControl1.TimeFormat = 0  'milliseconds
  MMControl1.To = HScroll1.Value
  MMControl1.Command = "Seek"
  MMControl1.Command = "Play"

Let me know if this helps, if it does I guess I can then submit it as an answer.
0
 

Author Comment

by:aquakid
Comment Utility
So that code that you have added to your answer is what I put in the Sub_Change of my Scroll Bar (Hscroll1) ??
0
 

Author Comment

by:aquakid
Comment Utility
So that code that you have added to your answer is what I put in the Sub_Change of my Scroll Bar (Hscroll1) ??
0
 

Author Comment

by:aquakid
Comment Utility
I tried everything I could think of with that code of yours and nothing would work!  What do you suggest?
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
The code that woodworker supplied would probably go in a command button.  Once a midi is playing you cannot change it's end point.  You will have to stop the midi and then use the scroll bar.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Expert Comment

by:woodworker
Comment Utility
My intent was for that to go in the scrollbar change event.  I don't have a sound card here at work, I had to use my cd player with headphones.  It worked fine on that, maybe a midi file is different.
0
 

Author Comment

by:aquakid
Comment Utility
Well, I have tried it all.  If you look at Microsoft's Media Player you can see what I am talking about.  and it doesn't seem that the midi file is being stopped and then played again in another spot.  Are you sure you don't have any other Ideas?  When I put your code into the CHange event in the Scroll Bar then it messes up because I have a timer telling the scroll bar to move according to the position of the MIdi file as it is being played. and everytime that it moves it is a change event.  SO I am confused right now.  Please, if you have any other Ideas then I would like to hear them.  Thank you all for helping me out here though.  I appreciate the help.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
A midi shouldn't be any different from a cd for this purpose.
I stand corrected.  Checking your code, this should work.

aquakid: What is the scrollbars Max property set to?  Do you set it to the Length property of MMControl (if not, you should)?
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
MS Media player doesn't use a scroll bar.  They use a combination of picture boxes. (one for the scroll area, one for the button)
0
 

Expert Comment

by:woodworker
Comment Utility
aquakid, I had to wait until I got home to play with this more.  I got it all to work with a midi file except for the flickering scroll bar.  I started to figure that out and now I have to leave for dinner.  here is my hacked together form code.  This keeps the flickering from happening until the first time you move the scroll bar.

Option Explicit
Private bChangedBySelf As Boolean

Private Sub Form_Load()
  MMControl1.Notify = False
  MMControl1.Wait = True
  MMControl1.Shareable = False
  MMControl1.DeviceType = "Sequencer"
  MMControl1.filename = "C:\WINDOWS\canyon.mid"

  MMControl1.Command = "Open"
  MMControl1.TimeFormat = 0
  If MMControl1.length < 32767 Then
    HScroll1.max = MMControl1.length
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  MMControl1.Command = "Close"
End Sub

Private Sub HScroll1_Change()
  Dim length As Long
  Dim factor As Long
  Dim max As Long
 
  If Not bChangedBySelf Then
    MMControl1.TimeFormat = 0
    length = MMControl1.length
    factor = 1
    max = HScroll1.max
    If length > max Then
      factor = length \ max
    End If
   
   
    MMControl1.To = (factor * HScroll1.Value)
    MMControl1.Command = "Seek"
    MMControl1.Command = "Play"
  End If
  Timer1.Enabled = True
End Sub

Private Sub HScroll1_GotFocus()
  Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
  Dim length As Long
  Dim factor As Long
  Dim x As Long
  Dim max As Long
'  Static bBusy As Boolean
'
'  If bBusy Then
'    Exit Sub
'  End If
'  bBusy = True
  Timer1.Enabled = False
  MMControl1.TimeFormat = 0
  length = MMControl1.length
  factor = 1
  max = HScroll1.max
  If length > max Then
    factor = length \ max
  End If
 
 
  x = MMControl1.Position
  bChangedBySelf = True
  HScroll1.Value = x \ factor
  bChangedBySelf = False
  Timer1.Enabled = True
'  bBusy = False
 
End Sub

0
 

Author Comment

by:aquakid
Comment Utility
Hey, I am at a different COmputer now, With out Visual Basic.  I looked over the code and I am sure It will work.  Thank you for all of your help guys!  I am very pleased with the hard work you have put into it.  Thanks again!

Jason Waters
aquakid@iname.com
http://come.to/aquakid/
0
 

Author Comment

by:aquakid
Comment Utility
will I be able to see this for future reference?
0
 

Accepted Solution

by:
woodworker earned 100 total points
Comment Utility
see text above
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now