MoviePlayer - Freeze on last second of movie + movie play doesn't work?

Hey guys,
Have the latest version of Xojo + Windows 8.1. I’m playing a movie file via MoviePlayer, and at the end of the video, it just goes black. Is there a way to “freeze” the movie on the final second, rather than just going to black?

Thanks!

[quote=198625:@Derek DiBenedetto]Hey guys,
Have the latest version of Xojo + Windows 8.1. I’m playing a movie file via MoviePlayer, and at the end of the video, it just goes black. Is there a way to “freeze” the movie on the final second, rather than just going to black?![/quote]

You could use Stop in a timer instead of letting the movie reach the end. But that requires measuring the exact play timer beforehand.

Another way is after the last movie, to display a still picture (I tested with a Jpeg), and go Stop immediately after Run. Then the MoviePlayer stays on Pause on the picture. It is a nice way to prevent showing a black screen.

in MoviePlayer.Stop

if me.Position = me.Duration then me.Position = me.Duration - 1 end if

Axel: Doesn’t seem to work. Then again, Looping + Palindrome don’t work either. Does the movie have to be a certain format? I’m using a .MOV file.

it works on OSX,
I had overlooked that you need Windows.
me.Position = me.Duration never work properly in Windows

I tested on Windows, and came up with the still picture…

Also, when I try to add a .MP4 directly into my project, it says ‘not a recognized sound file’. How do I add and play a .MP4 file in Xojo with Windows?

The only way I could do it is by using a folderitem. I am not sure this is exactly a bug, but it does look like one.

I did this:

Dim f As FolderItem f = GetFolderItem("startrace") MoviePlayer1.Movie = f.OpenAsMovie MoviePlayer1.Play

The control is named properly, and the file is in the running folder. It just displays a black square, no video. It’s in .MP4 format. The documentation says this should work (it’s listed as an example), but it doesn’t seem to, at least for me.

test this
copy startrace.mp4 to Desktop

Dim f As FolderItem f = SpecialFolder.Desktop.Child("startrace.mp4") MoviePlayer1.Movie = f.OpenAsMovie MoviePlayer1.Play

[quote=198722:@Axel Schneider]test this
copy startrace.mp4 to Desktop

Dim f As FolderItem f = SpecialFolder.Desktop.Child("startrace.mp4") MoviePlayer1.Movie = f.OpenAsMovie MoviePlayer1.Play[/quote]

That works fine. So how I get the video to play from the current running folder in the app?

does this work?

f = GetFolderItem(“startrace.mp4”)

Nope it doesn’t work. I think the documentation needs some updating. :slight_smile:

Anyone have any ideas?

[quote=198725:@Derek DiBenedetto]Nope it doesn’t work. I think the documentation needs some updating. :slight_smile:

Anyone have any ideas?[/quote]

Under Windows the debug executable is in a debug folder. And to make things worse, that folder is deleted after the debug run is finished.

Here is sample code from Tim Hare that takes that into account :

#if DebugBuild then f = getfolderitem("").Parent #else f = getfolderitem("") #endif

#if DebugBuild then
f = getfolderitem("").Parent.Child("startrace.mp4")
#else
   f = getfolderitem("startrace.mp4")
#endif

[quote=198733:@Michel Bujardet]Under Windows the debug executable is in a debug folder. And to make things worse, that folder is deleted after the debug run is finished.

Here is sample code from Tim Hare that takes that into account :

#if DebugBuild then f = getfolderitem("").Parent #else f = getfolderitem("") #endif[/quote]

Did this:

Dim f As FolderItem #if DebugBuild then f = getfolderitem("startrace").Parent #else f = getfolderitem("startrace") #endif MoviePlayer1.Movie = f.OpenAsMovie MoviePlayer1.Play

Still doesn’t play the video. Black square. Changing it to .mp4 on the end of the file name doesn’t work either.

[quote=198734:@Axel Schneider] #if DebugBuild then f = getfolderitem("").Parent.Child("startrace.mp4") #else f = getfolderitem("startrace.mp4") #endif [/quote]

This finally worked! Odd indeed. Now how I do I (in windows) freeze the video on the last second?

12 hours ago…

try this (in MoviePlayer1.Stop), if it does not work you must use a Timer.

if floor(MoviePlayer1.Position) = floor(MoviePlayer1.Duration) then MoviePlayer1.Position = floor(MoviePlayer1.Duration) - 1 end if

What code would I use for a Timer to pause the video at the 9th second (it’s a 10 second video)?