Solved

Play "tunes" sequentially

Posted on 2003-10-24
24
408 Views
Last Modified: 2013-12-18
I'm developing for Notes 5.04a - 5.08.

In my database postopen, I check to see if the user has some small sound files available in their tune list, and if they don't, I extract them from profile documents.

In another place in the database, I wish to be able to play these sound files sequentially. The problem is the ws.PlayTune("TuneName") command, if called more than once in a row, doesn't wait until the first "tune" has finished playing to play the second "tune" and so forth. So what you end up getting is only the last tune you played.

Each sound file is only about a fourth or a third of a second, and there will potentially be two dozen or so in a series. So I'd rather not have a long delay inbetween them, even of one second (which I know I could get by grabbing Now and then waiting until Now changes).

Can anybody recommend a way to play these little buggers one at a time without any significant delay?

Thanks.

-- b.r.t.
0
Comment
Question by:BarryTice
  • 11
  • 8
  • 5
24 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9615099
Use a playlist, and have a standard mmedia program play them for you.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9615131
Hi Barry,

Just a quick thought, if you are given a shell and wait program (i.e start a process and wiat for it to complete and then proceed for the next), woudl it suffice ur requirement

Partha
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9615208
Partha,

Your suggestion would not work with most music players, as the players return control imediately to the caller; you have no way of telling when they complete their work.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9615216
Another idea:

Embed a RealPlayer or Windows Media Player ActiveX control on a form, load up the form, and have the form's PostOpen script control the mebedded player so it plays the song.

If showing the form in the UI is an issue, then use a frameset.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9615326
The sequence of playing is not going to be consistent. It's going to change depending on document contents, and there are billions of possible permutations. Also, I haven't the corporate authority to mandate a standard media player.

Partha --

That might meet my needs, if the program itself is small enough. Some of our employees connect over dial-up, and I already feel bad pushing a dozen 16KB files to them the first time they open the database. 192 KB takes a while at over a 56K dial-up. (At least it's only once.)

Let me give more background, in case it triggers anything for you.

We have a crappy system we use for entering time every week that makes us call in to an automated system and punch in project and task numbers.

Because this crappy system isn't enough torture, my manager (and her boss) have decided that we all need to enter our time in one or two other places as well. At the moment, that's a status report done in a Word file and a time sheet on an Excel spreadsheet.

I've combined these last two into one Notes database that performs a series of lookups for all the numbers you have to push to enter your time over the phone. I can generate a report of what projects and tasks are used, and how many hours are logged to each day. I can even break that down into a string of phone buttons to push in what order.

Or, what I'd like to do, is let people dial into the timekeeping system, hold their receiver up to their computer speaker, click a button, and have the computer do all the beeping for them.

But a typical entry would be:

5#102403##01##10077##1516##4*5##5#102403##01##10077##1518##1##5##102403##01##11208##1509##2*5##

That's 4.5 hours on one project, 2.5 hours on another, and an hour in a staff meeting. Someone with fast fingers could get all that in in less than a minute, if the list is right in front of them. But with a one-second pause for each number, that's more than a minute and a half of holding the phone up to the speaker. With something that just played the tones in series, it would be, maybe, 20 or 30 seconds, tops.

And that's if all my time goes to just three projects. For people who are working on multiple projects, they might end up having to hold the phone up to the speaker for 5 minutes or more for each day's entry. That means doing all this for a whole week at once would make them hold the phone to the speaker for nearly a half hour, vs. six or eight minutes if I can optimize it somewhat.

Does this help?

-- b.r.t.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9615355
qwaletee --

How do I do the Windows Media Player activeX control? I could put a hidden field on the form to be my "playlist." Then, could I start the player using a button on the form instead of the form's post-open?

Thanks.

-- b.r.t.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9615577
Yes, you can.  You embed a WMP control on the form, then script it using LotusScript.

However, this may not be necessary.  If all this is to do some dialing, why not use a phone dialer program to do the whole work?  It can dial the phone number, too.

Pick up a free, small one on tucows or download.com
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9615592
Or, for that matter, use the Notes dialer.  I'd have to think about exactly how to get that to work, but at the very worst, you can on the fly create a connection document that will show up first n the list, and either bring up the dial-server dialog (with the server name acting as a prompt), or istruct the user how to do so.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9615709
qwaletee --

The phone dialers I've seen all require that you plug your phone line into the computer. First of all, not all computers here have a modem. Second, the phone lines to peole's desks are some digital system that goes through the main switchboard, so it's not a line that should be plugged into a normal modem. thirdly, for many people, even if they have a modem and the digital phone line weren't a problem, they would have to crawl under their desks to plug the phone line in to the back of their tower every time they wanted to submit their time.

Playing the beeps out through the speakers is a better solution for our needs, I think.

On my form, I've done Create -> Object, set it to control, and selected Windows Media Player. I now have that control on my form, and I see a series of events available for triggering things for it. I've also created a button on the form.

How, then, do I reference the player from the button? I don't know how to get a handle from it to reference it.

Also, I've tried putting some code in some of the control's events. But I can't seem to get it to respond.

For example, in the Click event I tried this:
Sub Click(Source As Mediaplayer, Button As Integer, Shiftstate As Integer, X As Long, Y As Long)
      Msgbox Str$(Button)
End Sub

But regardless of where I click on the control, I get no response. (Not quite true -- the Mute button on the player responds to a click by enabling or disabling the speaker, but nothing gives me the messagebox.) Similarly, I get no response from a Msgbox "Hello" in the Keypress event.

Any hints on this would be most appreciated.

(Points doubled to 250.)

-- b.r.t.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9616408
RE: Shell a 32-bit process and Wait till Finish...
Posted by Charles M Russo on 24.Sep.00 at 12:30 PM using a Web browser
Category: Domino Designer -- LotusScriptRelease: 5.0.2Platform: Windows NT
here's something I used a few years back; it's from a MS VB lib...


1. Place following in Declarations

Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (Byval _
hHandle As Long; Byval dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (Byval _
lpApplicationName As Long; Byval lpCommandLine As String; Byval _
lpProcessAttributes As Long; Byval lpThreadAttributes As Long; _
Byval bInheritHandles As Long; Byval dwCreationFlags As Long; _
Byval lpEnvironment As Long; Byval lpCurrentDirectory As Long; _
lpStartupInfo As STARTUPINFO; lpProcessInformation As _
PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (Byval _
hObject As Long) As Long

Const NORMAL_PRIORITY_CLASS = &H20&
Const INFINITE = -1&
------------------------------
2. a subroutine

Sub ShellAndWait(Byval RunProg As String)

Dim RetVal As Long
Dim proc As PROCESS_INFORMATION
Dim StartInf As STARTUPINFO
StartInf.cb = Len(StartInf)
'Execute the given path
RetVal = CreateProcessA(0&; RunProg; 0&; 0&; 1&; _
NORMAL_PRIORITY_CLASS; 0&; 0&; StartInf; proc)

'Disable this app until the shelled one is done
RetVal = WaitForSingleObject(proc.hProcess; INFINITE)
RetVal = CloseHandle(proc.hProcess)

End Sub

------------------
3. execution using a button.

Sub Click(Source As Button)
'When you're ready to shell out to the separate process; run this code:
ShellAndWait "notepad.exe"
'The next line will not execute until Notepad has closed.
Msgbox "Notepad has been closed."
End Sub

this can be used as a sample.... run each of the files, If there is no signifcant effect in performance
instead of notepad.exe, use ur media file one by one
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9616414
forgot to mention, in that change all semicolons to comma...


Partha
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9616767
No such luck, p_partha.

I put your code into an agent, with this as the Initialize sub:
==== BEGIN PASTE ====
      Dim strPath As String
      Dim intCount As Integer
      
      strPath = "C:\Winnt\media\Phone "
      
      For intCount = 0 To 9
            ShellAndWait strPath & Trim$(Str$(intCount)) & ".wav"
      Next
===== END PASTE =====

My 10 files are in my c:\WinNT\Media directory, and they are called "Phone 0.wav" through "Phone 9.wav". This should have worked, by your explanation.

Any other ideas?

-- b.r.t.
0
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!

 
LVL 14

Expert Comment

by:p_partha
ID: 9617139
ok just a thought to check wehther the code is working or not
change it to
shellandwait notepad.exe
shellandwait calc.exe


calculator shd popup only after notepad is closed


check it out and let me know

Partha
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9617156
Partha,

It isn't your code that's at fault.  The player is simply returning control as soon as it finishes initializing, and not waiting to complete playing the file.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9617228
Barry, the events for the player control are events generated by the player, when it is activated.  Frst, you need to externally activate the player, then use its properties and methods.  Here's Lotus's sample script for activation (from Designer help):

     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim item As Variant
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.Document
     Set item = doc.GetFirstItem("Body")
     If item.EmbeddedObjects(0) Is Nothing Then
          Messagebox "No embedded object in document"
          Exit Sub
     End If
     If item.EmbeddedObjects(0).Type <> EMBED_OBJECT Then
          Messagebox "Object not an embedded object"
          Exit Sub
     End If
     Call item.EmbeddedObjects(0).Activate(True)
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9617233
0
 
LVL 14

Expert Comment

by:p_partha
ID: 9617245
I think i got it, the next event will fire only when the window of the first wav is clsoed

it may finish, but there is no necessity that it might close.... so kind of confused ;-)

Partha
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9617608
FYI, I think you can do this without embedding the control on your form.  You can get a handle to an object using the LotusScript function CreateObject (which has nothing to do with NotesDocument, NotesItem, NotesRichTextItem, or NotesUIDocument).
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9618060
OK, so let's assume I have the active X control on the form. Using this code, I can get a grip on the control:
(form globals)
Dim varPlayer as Variant

(button code)
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
      
      Forall obj In doc.EmbeddedObjects
            If obj.Name = "Windows Media Player" Then
                  Set varPlayer = obj
                  Exit For
            End If
      End Forall
      
      Call varPlayer.Activate(True)

Great. Now what?

The link to www-10.lotus.com above tries to grab the object a different way. It uses:
dim vMP as variant ' To hold a handle to MP
set vMP = GetObject( "Windows Media Player" )
vMP.FileName = "mysoundfile.wav" 'The wav file you want to play back
vMP.play ' Starts playback


I've tried this, and get an "Automation object file name error" on the GetObject line. I've also tried it without the spaces (both in the code and on the object properties), just to make sure.

I've tried using varPlayer.FileName = "C:\WinNt\media\Phone 1.wav", but that gives me an "Instance member FILENAME does not exist" error.

Any other ideas? Everyone says it can be done, but nobody seems to know quite how to make it work!

-- b.r.t.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9618094
For what it's worth, when I try

      Dim vMP As Variant
      Set vMP = CreateObject("Windows Media Player")
      
      vMP.FileName = "C:\WinNt\Media\Phone 7.wav"
      vMP.SendPlayStateChangeEvents = True
      vMP.Play

I get a "Cannot create automation object" error.

-- b.r.t.
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 250 total points
ID: 9621381
Dunno, never actually used it practice.  You can probably get some idea of how it is done from a web site that uses its own controls to control WMP, and has WMP hide itself.

Or, you can create the object on the fly via the LotusScript function CreateObject (not related to any part of the Notes/Domino object models), and work from there.  Search MSDN for CreateObject and Windows Media Player.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9690767
I never did get the Active-X to work correctly (at all, really), and perhaps I'll come back to it at some point. But my bosses have an unfortunate habit of giving me "real" work to do every time I get involved in something that might be fun and useful.

For the moment, I'm exporting a playlist that can be read by WinAmp. In my initial tests, it works fine. I'm still waiting for results from other users.

Thanks for your help!

-- b.r.t.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9691569
I don't know that I deserved the award, though, much less an "A."
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9694026
The reward is less for the answer than for the effort put into it, qwaletee. While it's true you didn't actually solve my problem, you did recommend using a playlist -- which is the route I ended up taking. And if an A grade on this question makes you read and think about my next question, then I see no reason to grade you any lower, as it doesn't save me anything and it certainly doesn't do you any good.

Thanks for the assistance.

-- b.r.t.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 41 163
Lotus notes 3 294
Lotus Notes to MS Exchange mailfile migration 4 34
Lotus Notes Mailbox (Mail Forwarding) 9 32
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

14 Experts available now in Live!

Get 1:1 Help Now