Skip to content
View in the app

A better way to browse. Learn more.

Learn more

Service file not playing video

Featured Replies

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?

Guest
This topic is now closed to further replies.

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.