Tradition

This app allow us to recibe a random or a specific media such as photo, video or audio, and display it on the lcd display. Also we could finish projection with the same topic but with a message stop.

  • First we need to import the libraries that we are going to use.

import sys
import os,random
  • Explaining the code.

    • First we get the first parameter and save it on the variable "tipo", to know with time of media we are going to display

    • Then we storage the second parameter, as the message

    • We define the path were we have all ready the media.

    • Then we use some conditions to know is we receive a random name, or we need to stop the program, or if we need only need to storage the name of the media.

      • If we recibe random, we get a random name of files with the function random.choice(os.listdir.("path"))

    • Then we look of with type of media we are going to reproduce.

      • Sound we use mpg123

      • Image we use feh

      • Video se use cvlc

tipo = sys.argv[1]
message = sys.argv[2];
message = message.split("/")
path = "/home/lupe/Desktop/Data/"


if(message[1] == 'Random'):
  randomfile = random.choice(os.listdir(path+message[0]+"/"+tipo+"/"))
  file = randomfile
  nombre=file
elif(message[1] == "Stop"):
  os.system('killall -9 mpg123')
  os.system('killall -9 vlc')
  os.system('killall -9 feh')
  sys.exit()
else:
  nombre=message[1]

if(tipo == 'Sound'):
  path2 = path+message[0]+"/Sound/"+nombre
  print(path2)
  os.system('mpg123 '+path2)

elif(tipo == "Image"):
  path2 = path+message[0]+"/Image/"+nombre
  os.system('feh -F '+path2)

elif(tipo == "Video"):
   path2 = path+message[0]+"/Video/"+nombre
   os.system("cvlc --no-video-title-show --fullscreen "+path2)

else:
 print("error")

Last updated

Was this helpful?