Jump to content

Service file not playing video


ron123456

Recommended Posts

I have written a Python script that receives an online link from the server and downloads it and plays it simultaneously. After that, it plays it from the device unless it receives a new video link. 

I have written a service file that runs this code once the device boots.

 

Service Script


        [Unit]
        Description=My device boot script service
        After=multi-user.target

        [Service]
        Type=idle
        User=root
        Environment=DISPLAY=:0
        Restart=on-failure
        ExecStart=/root/Video_project/start.sh 

        [Install]
        WantedBy=multi-user.target

start.sh script

 

    #!/bin/bash
    #exec 1> >(logger -s -t $(basename $0)) 2>&1
    python /root/Video_project/main.py    

Python function to play video

 

I have these 3 functions running which displays the image and the video   

    def image_func():
        img_link = "https://i.ytimg.com/vi/o4IVan08VvI/maxresdefault.jpg"
        img_cmd = "feh -F %s"%(img_link)
        os.system(img_cmd)

    def play_video_from_server(link):
        print("Playing video from server")
        cmd = "mplayer -fs ffmpeg://%s" %(link)    #link is read from JSON file
        os.system(cmd)

    def play_video_from_device(link_ID):
        print("Playing video from Device")
        cmd = "mplayer -fs %s.mp4" %(link_ID)    #link_ID .mp4 is the name of the downloaded video
        os.system(cmd)


The video player and image viewer never open in the front screen. How should I make it run to view the image and video?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines