аватар question@mail.ru · 01.01.1970 03:00

Raspberry Pi + OMXPLAYER -WRAPER - starting video files in the right order by pressing buttons

Trying to launch video files with Raspberry Pi from a python. To do this, I use Omxplayer-Wrapper.

n

I try to implement the following algorithm:

n
    n
  1. At the beginning of the program, the a.mp4
  2. n
  3. when clicking button 1, A.MP4 stops and is tued on B.MP4. When it ends, an.mp4
  4. n
  5. is tued on again when the button is pressed, the.mp4 stops and tus on C.mp4. When it ends, an.mp4
  6. n n

    algorithm works again, but the following shortcomings are observed:

    n
      n
    1. after the B.MP4 file is finished before starting the A.MP4, the desktop is visible (approximately 1 second)
    2. n
    3. after the C.mp4 file is being lost to be lost. The launch of a.mp4 is visible the desktop for more time (approximately 10-12 seconds)
    4. n n

      how to carry out this task correctly?

      n

      I give a sketch of the code:

      n
         fromxplayer  Import  omxplaye  from  time  'path/to/a.mp4' , args = [ ''-b ', ' '-look' ]) nplayerb = Omxplayer ( 'path/to/b.mp4' , args = [ ''-b ']) nplayerc = omxplayer ( 'Path/to/C.mp4' , args = [ '-b' ]) nplayera.play () n  when>  true : n  if  button1pressedflag ==  true : #set in interrupt  n Button1pressedflag =  false  n playera.pause () n plasyerb.play () n  0.2 ) n Playerb.quit () n playera.play () n  if  button2pressedflag ==  true : #set in interrupt  n button2pressedflag =  false  n playera.pause () n playerc.play () n  blasses> when  Playerc tin. 
      is_playing either works, then does not work.
      where the is_playing () does not work, the function of playback_status (), although it is used in is_playing () ..
      quit () either kills the process, then no.
      stop () either stops the player, then kills the process of terrible porridge ..
      solved the problem of dirty Street:
      1. I am letting the video
      2. I take its duration and insert it into Sleep ()

      3. After the slip, I kill the video
      If you need to switch the video, then switching occurs in the interruption from the button.
      It seems to work ... but not beautiful somehow ...: (

аватар answer@mail.ru · 01.01.1970 03:00

I see 2 solutions to the problem. Or use PAUSE/Load

   fromxplayer  import  Omxplayer  from  gpiozero  import  buttonplayer = omxplayer ( '-b' ,  ''-look ']) button1 = button ( 1 ) button2 = button ( 2 ) player.play ()   when   true  if  button1.is_pressed:  Player.pause ()  Player.load ( 'path/to/b.mp4' )  player.play ()   elif  button2.is_pressed:  Player.pause ()  Player.load ( 'path/to/c.mp4' )  player.play ()     

 Class = "" Data-Highlighted = "">  fromxplayer  Import  omxplayer  gpiozero  import  button  from  threading  import  thirdadplayra = omxplayer ( 'path/to/a.mp4' , args = [ ''-b ', ' '-look' ]) playerb = omxplayer ( 'Path/to/B.mp4' , args = [ '-b' ]) playerc = omxplayer ( 'path/to/c.mp4' . Args = [ '-b' ]) current_player = Playranext_Player = Playerb  def   Load_next_video  ( player, video_path ):  Player.load (Video_path) load_thread = Thread_next_Next_VIDEO, args = (next_player,  'path/to/b.mp4' )) load_thread.start () button1 = button ( 1 ) bututon2 = Button ( 2 ) current_player.play ()   when   trye :   elif  button2.is_pressed:  current_player.pause ()  next_player.pause ()  current_player, next_player = next_player, Current_Player Load_thread = Thread = Load_next_video, Args = (Next_Player,  'Path/to/C.Mp4' )) )) Current_Player.play ()     

there is no device, I can not check. I threw it out of old memory, I hope it will work.

Latest

Similar