Looping video

Discuss any general programming issues here
User avatar
Juan Carlos
Posts: 884
Joined: Mon Sep 06, 2010 1:02 pm

Re: Looping video

Post by Juan Carlos »

To aovid the first black frame you can use the instruction SeekVideo and gives it the frame with image, the song like background you can use the tirck StopMusic(1) and after PlayMusic(1, 1).
User avatar
Juan Carlos
Posts: 884
Joined: Mon Sep 06, 2010 1:02 pm

Re: Looping video

Post by Juan Carlos »

The code for you:

Code: Select all

@REQUIRE "oggvorbis"
@REQUIRE "avcodec"

@VIDEO 1, "Videos/RomBoot3-0.mp4"
@MUSIC 1, "Melodias/TheCrackSong01.ogg"

Function p_IntroVideo()
  ;Also you can jump to music start
  SeekMusic(1, 1000) ;Jump to 1000 miliseconds to avoid the silence start.
  PlayMusic(1, 1) ;1 to infinite times, 0 to once. 

  SeekVideo(1, 1000) ;Jump to 1000 miliseconds to avoid the black first frame.
  PlayVideo(1, #CENTER, #CENTER)
EndFunction

Function p_Main()
  ;This to play the video in loop:
  StopMusic(1) ;Stop the background song when the video is finish.

  p_IntroVideo() ;Here the program goes to p_IntroVideo() to play it in loop.
EndFunction

;Main function to run this program.
p_IntroVideo()

InstallEventHandler({OnVideoEnd=p_Main})

EscapeQuit(True)
Repeat
  WaitEvent
Forever
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Looping video

Post by airsoftsoftwair »

If your aim is to have videos looping seamlessly, this is not possible. I think it's impossible to loop videos without a very short pause between the individual cycles...
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Looping video

Post by ocean77 »

Juan Carlos wrote: Fri Aug 28, 2020 3:50 pm The code for you:

Code: Select all

@REQUIRE "oggvorbis"
@REQUIRE "avcodec"

@VIDEO 1, "Videos/RomBoot3-0.mp4"
@MUSIC 1, "Melodias/TheCrackSong01.ogg"

Function p_IntroVideo()
  ;Also you can jump to music start
  SeekMusic(1, 1000) ;Jump to 1000 miliseconds to avoid the silence start.
  PlayMusic(1, 1) ;1 to infinite times, 0 to once. 

  SeekVideo(1, 1000) ;Jump to 1000 miliseconds to avoid the black first frame.
  PlayVideo(1, #CENTER, #CENTER)
EndFunction

Function p_Main()
  ;This to play the video in loop:
  StopMusic(1) ;Stop the background song when the video is finish.

  p_IntroVideo() ;Here the program goes to p_IntroVideo() to play it in loop.
EndFunction

;Main function to run this program.
p_IntroVideo()

InstallEventHandler({OnVideoEnd=p_Main})

EscapeQuit(True)
Repeat
  WaitEvent
Forever
Thank you. It almost works. The black frame is still there. And the music needs to be played outside the loop.

airsoftsoftwair wrote: Sun Aug 30, 2020 10:26 pm If your aim is to have videos looping seamlessly, this is not possible. I think it's impossible to loop videos without a very short pause between the individual cycles...
It worked brilliantly in Designer, no visible seam at all. But with the hand coded project it doesn't work properly. And I don't really understand what to do about it.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Looping video

Post by airsoftsoftwair »

ocean77 wrote: Sun Aug 30, 2020 11:16 pm It worked brilliantly in Designer, no visible seam at all. But with the hand coded project it doesn't work properly. And I don't really understand what to do about it.
That is strange. How did you make it loop in Designer? Using action events?
ocean77
Posts: 111
Joined: Mon Jan 28, 2019 8:34 pm

Re: Looping video

Post by ocean77 »

airsoftsoftwair wrote: Tue Sep 01, 2020 8:33 pm
ocean77 wrote: Sun Aug 30, 2020 11:16 pm It worked brilliantly in Designer, no visible seam at all. But with the hand coded project it doesn't work properly. And I don't really understand what to do about it.
That is strange. How did you make it loop in Designer? Using action events?
My sincerest apologies. I went back and checked. I was experimenting with different formats to see what would work best as playback was so slow. Apparently I used an anim5 file in Designer. I assumed the options would be the same as for a video, but they are not.
Sorry for the confusion.
Post Reply