Snap running other snap can't read files in home dir

I’m working on this problem and trying to solve it via my own snap package installed in devmode (not going for elegance here). I think I’m most of the way there but I’ve hit a wall. I’ve created a snap that runs omxplayer-pi successfully, but it can’t play a video in my home dir (while running omxplayer-pi on its own can play a video in my home dir).

The snap is one shell script so far. Here’s vplay.sh:

#!/bin/bash

while true
do
  sleep 10
  /snap/bin/omxplayer-pi --no-osd --loop /home/meonkeys/fireplace.mp4
  sleep 30
done

Here’s my snapcraft.yaml file:

name: vplay
version: '0.1'
summary: Play a video.
description: |
  Try really hard to play a video.
grade: devel
confinement: devmode
base: core18
architectures:
  - build-on: amd64
    run-on: all
apps:
  vplay:
    command: bin/vplay.sh
    plugs:
      - home
    daemon: simple
parts:
  vplay:
    plugin: dump
    source: .

I install it on the raspberry pi host with sudo snap install --devmode vplay_0.1_all.snap

The only output from omxplayer-pi is have a nice day ;), which I’ve also seen running omxplayer-pi test.mp4 on its own (directly from the command line) before I ran snap connect omxplayer-pi:home :home.

Is there some way to “pass on” whatever permissions omxplayer-pi has so when invoked from vplay it’ll work the same?

Hmm, should I actually package an omxplayer-pi pre-built binary inside my snap instead?

as i answered by mail already :slight_smile: …you should simply wrap your snap app around the original omxplayer-pi source and utilize it internally from a wrapper script or some such … the omxplayer-pi source is at:

https://github.com/ogra1/omxplayer-snap

and an example how to use it with some tool wrapped around (here two small shell scripts and a html page that create an IPTV player fo german TV stations) can be found at:

https://github.com/ogra1/iptv-player-snap

that should give you some impression how to create a snap that includes omxplayer as a backend …

i’ll eventually add a service to the omxplayer-pi snap itself that you can manually configure to do simple tasks like looping a video automatically or stream a single webstream automatically right after boot.

and for future debugging … to get more than “Have a nice day!” out of the player when something is wrong, you can just add switches like -I, -i and -s to get more info … (if you run omxplayer-pi without any options/file or with -h/–help it will print its help page for all possible options).

2 Likes

Thank you! This is very helpful.

Do you recommend building this on the raspberry pi? I’m trying that now on a modified version of iptv-player-snap and it is very slow. I’d rather have a chroot environment on a powerful workstation for cross-compiling for armhf, but I forget how to set all that up. Once I publish my fork I can probably just use launchpad or travis.ci, but I’m not ready for that yet.

Also, re: simple video looping, https://github.com/adafruit/pi_video_looper might be a good starting point.

well, you will definitely have to do one or the other local build and for that native is still best (for this particular snap). while you can cross-build the vc4 libs and omxplayer pretty easily, the snap also builds ffmpeg (to link against vc4) which has a lot of build dependencies … while it might be possible to cross build it with jumping through a lot of hoops, i have not tried that …

i do my initial builds on an old sabrelite board i have lying around and simply go for a coffee when it builds :slight_smile: but once i have a building snap i simply leave all the building to https://build.snapcraft.io, do my changes in github and use the edge channel as testing ground.

1 Like

Roger that.

Update: I got my fork to work!

Thanks again for your help.

2 Likes