INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Autostart and autoplay on Pi is not working, I think  (Read 8691 times)

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Autostart and autoplay on Pi is not working, I think
« on: November 16, 2016, 06:40:19 am »

I have a Raspberry Pi 3 B that I'm planning to put in my car (a Volvo XC60 with a 7" screen where I'm adding a video input). But I would like to have automatic startup and playback when the Pi starts. I have set both those in the options for MC, but it doesn't want to play ball. Is there something I must do extra, or is it not possible to get that working on a Pi?

Edit: I got the autoplay to work (play Playing now on start of program) after a few restarts, but still no autostart of MC when starting Rasbian.
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #2 on: November 16, 2016, 08:44:25 am »

Hi, Jim! No, I'm not going to use it as a DLN playback device, but as a standalone computer with MC with a 2 tb external disk connected to it. I followed the guide "Quick Start Guide for Installing JRiver Mediacenter 22 ARM on a Raspberry Pi".
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #3 on: November 16, 2016, 04:12:45 pm »

Hi, Jim! No, I'm not going to use it as a DLN playback device, but as a standalone computer with MC with a 2 tb external disk connected to it. I followed the guide "Quick Start Guide for Installing JRiver Mediacenter 22 ARM on a Raspberry Pi".

The autostart menu item won't work in MC for Linux, you have to configure MC to autostart separately (via script or systemd).  There's a script that does exactly this under the remote access section of the quick start guide.  You can also write a systemd service if you're on Jessie or later (I can furnish one too if that's your preferred route).
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #4 on: November 17, 2016, 01:47:09 am »

I see, thanks! Well, I do already have VNC running (Real VNC is a part of the Pi 3 B Raspbian), so that's not needed. What I want to do is to have MC running at all times, so I see what I need to do, I think. But I spent a bit of time getting Bluetooth audio working, so I don't want to break anything now. I'm totally fresh on this stuff, as opposed to Windows. So I really would like input on if this is correct:

Type:

Code: [Select]
sudo nano ~/mcbluetooth
And then:

Code: [Select]
#!/bin/bash
export USER=pi
export DISPLAY=':1'
ps -e | grep pulseaudio || pulseaudio
ps -e | grep mediacenter || mediacenter22 %F

Once you're done, press CTRL-X, and choose "y" and press "enter" twice.  Now type

Code: [Select]
* * * * *   /home/pi/mcbluetooth > /dev/null
I would think that's about correct, but I'm not sure at all. Also I'm not sure if %F is the correct argument for Media Center (it's the argument used in the shortcut in Raspbian). And what I'm especially not clear about is wether the DISPLAY line is necessary in my case. This is not for running headless, I will have the car display connected to the three way minijack. I only want PulseAudio (BlueTooth audio) and MC to start automatically.
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #5 on: November 17, 2016, 05:22:15 pm »

I see, thanks! Well, I do already have VNC running (Real VNC is a part of the Pi 3 B Raspbian), so that's not needed. What I want to do is to have MC running at all times, so I see what I need to do, I think. But I spent a bit of time getting Bluetooth audio working, so I don't want to break anything now. I'm totally fresh on this stuff, as opposed to Windows. So I really would like input on if this is correct:

Type:

Code: [Select]
sudo nano ~/mcbluetooth
And then:

Code: [Select]
#!/bin/bash
export USER=pi
export DISPLAY=':1'
ps -e | grep pulseaudio || pulseaudio
ps -e | grep mediacenter || mediacenter22 %F

Once you're done, press CTRL-X, and choose "y" and press "enter" twice.  Now type

Code: [Select]
* * * * *   /home/pi/mcbluetooth > /dev/null
I would think that's about correct, but I'm not sure at all. Also I'm not sure if %F is the correct argument for Media Center (it's the argument used in the shortcut in Raspbian). And what I'm especially not clear about is wether the DISPLAY line is necessary in my case. This is not for running headless, I will have the car display connected to the three way minijack. I only want PulseAudio (BlueTooth audio) and MC to start automatically.

Two things:

The recommended way to start pulse is using the builtin systemd service, not using a cron script.  To do that, try "sudo systemctl enable pulseaudio" that should set it to start on reboot and every reboot thereafter.  Pulse is a full sound stack by the way (analogous to direct sound on windows), it just happens to also do bluetooth.  You will get into grief trying to start pulse as a user service via cron.

As to MC, don't use the %F modifier, I would advise not passing any flags at all if you plan to use the GUI.  You will need to export the DISPLAY environment variable, but it may not be :1.  :1 is the virtual display generated by the VNC client, the default display is normally :0, but that's not guaranteed.  My advice is to open a terminal on the desktop you want to see MC on, and type
Code: [Select]
echo $DISPLAY.  The output of that command is what you need to export into the script so it knows where to send MC.  The DISPLAY variable should be the same across reboots unless your vncserver is extra weird (I've never used Real VNC)
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #6 on: November 18, 2016, 06:37:51 am »

Weird, the systemctl said something about that it couldn't find the directory.

But worse, when I copied my music to an external drive and connecte that to the Pi, and corrected the file path it couldn't play anything. It didn't find the files even if the path was correct. Does Raspbian have some file path limit that I don't know about? I can see the files fine in file manager, and I can open them from the open window in MC, but they still won't play. The files I have under Music (a few albums for test) work as they should. I really feel like a clutz with these tings...
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #7 on: November 18, 2016, 07:34:25 am »

Weird, the systemctl said something about that it couldn't find the directory.

You'll need to post the actual command and error, I'm not sure what that means.

Quote
But worse, when I copied my music to an external drive and connecte that to the Pi, and corrected the file path it couldn't play anything. It didn't find the files even if the path was correct. Does Raspbian have some file path limit that I don't know about? I can see the files fine in file manager, and I can open them from the open window in MC, but they still won't play. The files I have under Music (a few albums for test) work as they should. I really feel like a clutz with these tings...

Linux doesn't have a path limit, but the path structure is pretty different than windows.  When you say you "corrected the file path" what do you mean?  Where did you correct it and what did you correct it to (please provide an example of the actual path entered)?  Mounting external drives in Linux in a way that will be useful to MC may take a little care. 

For example, the OS will automount the drive no problem, but there's no guarantee the auto-mount path will be the same every time it mounts (kind of like windows assigning arbitrary drive letters to removeable drives).  So you should set the Pi to automatically mount the drive in the same place every time.  You can find some info on that in this thread: https://yabb.jriver.com/interact/index.php/topic,103584.msg719910.html
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #8 on: November 18, 2016, 01:09:00 pm »

Thanks for helping me! I'll get back to you on Sunday, I had to take a trip today until late tomorow night.
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #9 on: November 20, 2016, 09:48:16 am »

sudo systemctl enable pulseaudio

gives the result

"Failed to execute operation: No such file or directory"

pulseaudio --start

fires up Pulse Audio

As for the files I had overlooked a setting, "Convert Windows File Path Syntax to Mac/Linux". So running a replace of Z: (from the file path z:\Media\Pi\MP3\Album\Genre\Artist - Album title) with nothing in the replace with box, the mentioned box ticked and "Replace slashes in expressions". But it seems like no matter what USB port I plug the drive in, it will always go into /Media/Pi/MP3 when it's mounted. If I keep the name of the station the same, doesn't it mean that this will be constant?
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #10 on: November 20, 2016, 10:01:07 am »

sudo systemctl enable pulseaudio

gives the result

"Failed to execute operation: No such file or directory"

pulseaudio --start

fires up Pulse Audio

That's bizarre; it's like they shipped pulse without the upstream service.  You are running the modern version of raspbian right (Jessie) right? Not Wheezy?

If you're running Wheezy that explains it, and stick with the cron script for now.  If you're running Jessie try this: http://raspberrypi.stackexchange.com/questions/639/how-to-get-pulseaudio-running/44767#44767

Quote
As for the files I had overlooked a setting, "Convert Windows File Path Syntax to Mac/Linux". So running a replace of Z: (from the file path z:\Media\Pi\MP3\Album\Genre\Artist - Album title) with nothing in the replace with box, the mentioned box ticked and "Replace slashes in expressions". But it seems like no matter what USB port I plug the drive in, it will always go into /Media/Pi/MP3 when it's mounted. If I keep the name of the station the same, doesn't it mean that this will be constant?

Not necessarily.  You may get lucky and it may always put it in the same place, or you may not (especially if you ever plug in any other drives).  I'm not sure what "station" means in the "name of the station" though, so I may be missing something?  Give it a try, and if MC can't find your media at some point, you know a more permanent fix.
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #11 on: November 20, 2016, 10:05:21 am »

Well, I installed from the latest version of NOOBS. But Pulse Audio was not a part of that. I found that here: https://www.raspberrypi.org/magpi/bluetooth-audio-raspberry-pi-3/

It told me to run this command:

Code: [Select]
sudo apt-get install pi-bluetooth blueman
And then this:

Code: [Select]
sudo apt-get install pulseaudio pavucontrol pulseaudio-module-bluetooth
So maybe something is missing?

With "name of station" I actually meant volume name, sorry. It was a bad direct translation from Norwegian computer lingo to English!  :-[
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #12 on: November 20, 2016, 12:02:56 pm »

Well, I installed from the latest version of NOOBS. But Pulse Audio was not a part of that. I found that here: https://www.raspberrypi.org/magpi/bluetooth-audio-raspberry-pi-3/

It told me to run this command:

Code: [Select]
sudo apt-get install pi-bluetooth blueman
And then this:

Code: [Select]
sudo apt-get install pulseaudio pavucontrol pulseaudio-module-bluetooth
So maybe something is missing?

The issue is that pulse normally ships with a service that you can enable.  The link I posted in my last post includes a replacement service you can use easily, so it's not an issue.  Just weird that Raspbian isn't shipping the default pulse service if you see my point.
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #13 on: November 21, 2016, 03:38:35 am »

I think I understand. You mean that the repository (I think it's called that...) doesn't contain the service? And sorry if I seem dense, but I couldn't get it to work with the link to the "How to get PulseAudio running?" thread either. But it gave me ideas and I found this:
http://raspberrypi.stackexchange.com/questions/50309/pulseaudio-not-autostarting-on-pi-3

So basically I had to edit the autostart file. Like this:

Code: [Select]
sudo nano /etc/xdg/autostart/pulseaudio.desktop
And then delete everything in the file (which took some time since I couldn't get Nano to select and delete lines, only hold down the Del tast to delete one by one character...). Then I copied in this tekst from the page above:

Code: [Select]
[Desktop Entry]
Version=1.0
Name=PulseAudio Sound System
Exec=/bin/sh -c "sleep 10; pulseaudio --start"
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
NotShowIn=KDE;

To quote the guy who wrote it (flittermice):
Quote
Sleeping for a few seconds seems to be important!

So now I have Pulseaudio starting as it should, and I can go on to Media Center autostart. And then I have to find out why I have a problem connecting to my car audio system. It either connects as "unknown" or "handsfree", and none of them works for streaming. The display in the car says "streaming", but there's no sound. I really hope I can get this working, I have spent quite a few hours on this now...but that's me. I am rather stubborn, and I want stuff to work!  >:( I hope that I can get it to display the track info in the car display, like when I stream from an Android phone. That is unfortunately not working when I stream from MC in Windows, it only shows "Windows Audio", and that just won't do. The quest for a working setup continues in the Pi!
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #14 on: November 21, 2016, 04:14:05 am »

Well, not there yet...  :-[ I used the command

Code: [Select]
sudo nano ~/mcbluetooth
to create the script file, and then filled it like this (after checking the correct display, which was :0.0):

Code: [Select]
#!/bin/bash
export USER=pi
export DISPLAY=':0'
ps -e | grep mediacenter || mediacenter22

that gave the error mesage:

Quote
bash: Desktop: command not found

So I tried like this:

Code: [Select]
#!/bin/bash
export USER=pi
export DISPLAY=':0.0'
ps -e | grep mediacenter || mediacenter22

But got the same result. Do you have any idea why it doesn't want to play ball?
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #15 on: November 21, 2016, 05:26:50 pm »

Did you by chance skip the chmod line in the Pi instructions (after the script but before the part where you open the crontab)?  i.e. did you remember to run "sudo chmod 755" on the file?

That error is the one the shell gives when the file in question hasn't been marked executable.
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #16 on: November 22, 2016, 02:18:30 am »

Actually it was a lot worse... Sorry for bothering you with my stupidity! I tried to run the line from the command line to test it before I added it in Crontab, I thought that would work, like a command run in a batchfile in DOS!  :-[ :-[ :-[ When I added the line to Crontab instead and did a reboot, MC came up running when I rebooted! So thanks a lot, I think I'm almost there! Now I only need to get the streaming to my car audio working, but I'm guessing that you do not have a Volvo between 2011 and 2014 with Sensus Audio so you can hold my hand there too! ;D But maybe you do know if it's possible to change the profile in Pulse Audio from handsfree to headset for something?
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #17 on: November 22, 2016, 05:24:37 pm »

Actually it was a lot worse... Sorry for bothering you with my stupidity! I tried to run the line from the command line to test it before I added it in Crontab, I thought that would work, like a command run in a batchfile in DOS!  :-[ :-[ :-[ When I added the line to Crontab instead and did a reboot, MC came up running when I rebooted! So thanks a lot, I think I'm almost there! Now I only need to get the streaming to my car audio working, but I'm guessing that you do not have a Volvo between 2011 and 2014 with Sensus Audio so you can hold my hand there too! ;D But maybe you do know if it's possible to change the profile in Pulse Audio from handsfree to headset for something?

Sorry, I don't really use Pulse much, and when I do it's in a simple desktop config.  I've found that some of the more "exotic" Pulse audio modules are not always very well implemented, but other than that I can't provide much guidance I'm afraid.  I also have an old car, so I'm not even sure what "hands free" means in this context  :-[
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #18 on: November 23, 2016, 01:33:02 am »

He-he, well you've helped me plenty anyway, so thanks a lot!  ;D And hands free in this context means that a phone connects to the car system, and there's a built-in microphone in the ceiling of the car, and the other caller's voice comes through the audio system. :) And in Pulse the car system shows like one of those phone headsets that are clamped around one of the ears.
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Autostart and autoplay on Pi is not working, I think
« Reply #19 on: November 23, 2016, 08:41:09 am »

He-he, well you've helped me plenty anyway, so thanks a lot!  ;D And hands free in this context means that a phone connects to the car system, and there's a built-in microphone in the ceiling of the car, and the other caller's voice comes through the audio system. :) And in Pulse the car system shows like one of those phone headsets that are clamped around one of the ears.

Oh I see.  My wife's car has something like that.  You're trying to use pulse to do the hand off there?  I'll be interested to know how you work that out, it sounds neat.
Logged

Mastiff

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1988
  • The Multi-Zone Tzar
Re: Autostart and autoplay on Pi is not working, I think
« Reply #20 on: November 23, 2016, 08:42:59 am »

Well, the Volvo searches for the BT device and stores it as the profile it gets. The problem is that the Pi is telling it that it is a handsfree phone, not a media player. So I hope I can force it somehow. I'll let you know if I solve it!
Logged
Tor with the Cinema Inferno & Multi-Zone Audio system
Pages: [1]   Go Up