On 09/09/10 00:27, NoOp wrote:
On 09/08/2010 09:23 AM, Mike Scott wrote:
...
Useful link, and so close.....

I can now run a video player (mplayer, incidently, seems to be an
appropriate one) from within Impress. I can set an event so clicking on,
say, some text, runs the macro. But what I simply cannot fathom is how
to trigger a macro when a particular slide transition occurs (so that
'next slide' effectively starts the video display).

Code given at
http://user.services.openoffice.org/en/forum/viewtopic.php?f=10&t=31312
provides a way to trigger something on /every/ slide change (not that I
can see yet how to run code when a document is loaded; I've been
hand-stepping with the debugger. Sort that one later :-)  And the code
looks problematic anyway - fails when run with 'run macro' but runs when
single-stepped with the debugger. Oh well....).

Any ideas about triggering a given macro on a given slide change please??

Unfortunately I know zip about macros. Sorry. However, instead of
mplayer, you might experiment with cheese or guvcview for the live
camera feed depending on the camera you are using.

Hmmm. 'discuss' didn't come up with concrete ideas, while 'dev' produced no suggestions at all :-{

So, after much head-scratching and rummaging around on the net, I have produced a partial solution. Basically, the idea is to set up a listener (as above) that is called for /every/ slide change. That then scans the objects on the current slide looking for anything with a particular name. If found, the appropriate macro is called which shells out and starts or stops the video display.

Code appended - untidy, 'in progress', and very, very horrid in at least one place where the presentation starts asynchronously with the macro. Much gleaned from examples on the net (in particular Andrew Pitonyak's stuff was instructive - thanks!!!)

There's still the problem of focus and window stack order - I'm starting MPlayer, which starts on top of the presentation (good) and steals the keyboard and mouse focus (bad!!). I'm now looking at xdotool as a way of scripting a shift of focus back to Impress. There's hope yet!

(Hopefully if someone else hits a similar problem, they might find this as a starting point, which is why I'm posting the code. Mind the line wrap!)


Mike Scott


=== CODE ===
Sub Main
        startup()
end sub


' the following is to be called for every slide change. It looks for an element on ' the current slide named either STARTVIDEO or STOPVIDEO, and calls the relevant
' start or stop routine (which will shell out)
Sub checkstartstop
  Dim i As Integer
  Dim c As Object
  dim n as String
  dim l as object

  c = ThisComponent.Presentation.Controller
  l = c.CurrentSlide.Links
'  print ubound(l.ElementNames)
  for i=0 to ubound(l.ElementNames)
    n = l.ElementNames(i)
'    print "element " & i & "  name " & n
    if l.ElementNames(i) = "STARTVIDEO" then
      StartVideo()
 '           print "start"
    elseif l.ElementNames(i) = "STOPVIDEO" then
      StopVideo()
      '      print "stop"
    end if
  next

  End Sub


' This is called once. It will start the presentation
sub startup
  dim doc as object
  dim presentation as object
  dim listener as object

    Doc = ThisComponent
  Presentation = Doc.Presentation
Listener = createUnoListener("EV_","com.sun.star.presentation.XSlideShowListener")
  Presentation.Start()
  wait 100 ' eeeek!!!!!
  Presentation.Controller.addSlideShowListener(Listener)

end sub


' a full set of listener sub's must be defined
Sub EV_paused(oEv)
End Sub

Sub EV_resumed(oEv)
End Sub

Sub EV_slideTransitionStarted(oEv)
'print "change"
  checkstartstop()

End Sub

Sub EV_slideTransitionEnded(oEv)
End Sub

Sub EV_slideAnimationEnded(oEv)
End Sub

Sub EV_slideEnded(oEv)
End Sub

Sub EV_hyperLinkClicked(oEv)
End Sub

Sub EV_disposing(oEv)
End Sub



' shell out to do the work
Sub StartVideo
  Shell("/home/mike/ooo-video-test/start.sh",2)
End Sub

Sub StopVideo
  Shell("/home/mike/ooo-video-test/stop.sh",2)
End Sub

=== ===



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to