Callbacks in Windows in LC8
Peter Bogdanoff
bogdanoff at me.com
Mon Sep 12 17:31:14 EDT 2016
I’m happy to report that callbacks seem to be working with DirectShow in Windows in LC 8.1 RC2.
Basic:
Callbacks are a property of a player. They are basically are a list of numbers, each line followed by a message name. The number corresponds to a time in a movie/audio file loaded into a player. When the player reaches that time, it sends the message. This is useful to have things happen in time synced to the progress of a movie.
Advanced:
I already have these callback lists prepared while I was working with .mov files on Mac and Windows. With the deprecation on QT in Windows, I’m converting those files to wma/wmv.
Integral to the use of callbacks is the timeScale property of a file. The timeScale is a number of intervals or blocks per second in a movie. The files I had already created with the QuickTime player all have a timeScale of 600. So when a player plays, these are the numbers that correspond to the progress of time.
After converting a MOV file to WMV, I’ve found that the timeScale went from 600 to 10,000,000.
So 10,000,000/600 yields a constant of 16,667. That's the number I use to multiply each callback number I already have to play in Windows. And it seems to work.
Panos suggested:
> Now, regarding your question, I am not 100% sure but I think that
> the Windows player reports always longer duration compared to OSX, but this
> multiplier is not constant, it differs depending on the audio/video file.
> This is why I suggest setting the callbacks as a fraction of the duration,
> since this will work cross platform. i.e.
>
> (duration/8),callback1
> (duration/6),callback2
> (duration/2),callback3
> ...
I did not have to do anything with the duration. The cross-platform conversion where I know the original timeScale in QT, and the original callback in QT:
(timeScale as WMV / timeScale as MOV) * existing callback in QT = callback in DirectShow
To get the timeScale of a file, you have to first load it into a player and then issue:
put the timeScale of player “Player” into tVar
However, the player in an existing stack reported a timeScale of not 10 million, but 10,000. So there is variation in the timeScale which affects the duration correspondingly. So the algorithm above has to be used.
That existing stack also crashes in the runtime at the point in the script where the callback is set. It works properly in the IDE. I haven’t tracked down why, but the stack is part of a large project. If I run that stack in isolation in the runtime environment, it works properly, and now has a timeScale again of 10 million. Perhaps when the player reports a timeScale of 10 thousand there is something wrong and it then causes a crash.
Otherwise… having callbacks working in native Windows is a huge deal for my multimedia application, Music In the Air, and I’m very grateful to Panos and the LC team for getting it working in LC8!
I’m planning to move the app in the future to HTML5 and would love to see a player with callbacks working there… :)
Peter Bogdanoff
More information about the use-livecode
mailing list