PDA

View Full Version : USB OTG support



pastraga
July 2nd, 2017, 08:15 PM
A USB OTG adapter provides a very convenient means to add storage to an Android phone.
Once plugged to the phone's micro-USB connector, one can connect a USB stick with music to the other end.
However, it seems that foobar2000 can't see the connected stick.

It is possible to use it, though, but in a very crude way: using a file explorer (e.g. ES File Explorer) it's possible to navigate to the device, open the required folders until one reaches the music files; after that, clicking on the file it's possible to open it with foobar2000.
However...
- it's necessary to select and click each file in order to play it (no lists);
- obviously, files on the stick do not appear in the library.

There's really no support to USB OTG (or maybe my device is not compatible)?
Would it be possible to add support to USB OTG?

foomobile
July 3rd, 2017, 04:33 AM
I have the same issue on my Windows Phone

foomobile
July 3rd, 2017, 04:37 AM
I need to add that Foobar mobile can see my USB(-C) stick as E:, but it says it can't access the files on it

Peter
July 3rd, 2017, 09:06 AM
With Android, you should be able to add USB stick music folders to your library just fine. If you can't, please state details: foobar2000 version, Android system version and full device name.

With Windows Phone, not tested but I don't see why it wouldn't work. Will test before the next update.

pastraga
July 3rd, 2017, 10:48 AM
With Android, you should be able to add USB stick music folders to your library just fine. If you can't, please state details: foobar2000 version, Android system version and full device name.

With Windows Phone, not tested but I don't see why it wouldn't work. Will test before the next update.

foobar2000 version: 1.0.79 lite
Android system version: 7.0
Phone: Motorola Moto G 5
OTG Adapter has no name in it. Android System reports the stick's brand (SanDisk USB drive). ES File Explorer shows it as either USB1003 or USB1004 or USB1005 (changes each time the stick is plugged).

pastraga
July 10th, 2017, 05:57 PM
Update
Tried another OTG adapter, but foobar2000 doesn't see it either.
Looked for a folder in Internal Storage; there are only the usual ones.
As with the other adapter, it's possible to navigate to the folders in the USB stick and play the files one by one.

pastraga
July 11th, 2017, 07:28 AM
New update
As I said before, I can play each file, one by one, after navigating to them with with ES File Explorer.
Tried another way:
Clicked on the USB icon; a new screen opened whose title is the USB stick's Windows label. Clicked on the music folder, then on a file - three options were offered to me:
- BubbleUPnP;
- foobar2000;
- Google Play Music.
Was able to play with BubbleUPnP and Google Play Music but not with foobar2000!
Note that if I reach the files with ES File Explorer I'm able to play them with foobar2000.

Peter
July 14th, 2017, 01:34 AM
I presume you've turned modern folder picker off in advanced settings.

As with new Android versions, it appears to be entirely impossible to talk to external USB storage using 'classic' POSIX programming interfaces. The devices do not appear anywhere under /storage, /mnt, whatever, hence foobar2000's own folder picker doesn't see them. I sincerely hope I that am wrong here and there's some obvious way around this; if you know better, please do tell me and I'll amend foobar2000 code to deal with this properly.

The current solution for reading music from USB storage is to use the modern folder picker to add USB storage folders, and have all file access routed through Android's DocumentFile Java classes. However, this makes music indexing insanely slow, that's why people have been avoiding the modern folder picker. Again if you've heard of a better programming solution, please do tell me.

pastraga
July 14th, 2017, 05:43 AM
I had left Advanced Settings in their default settings.
Checked and saw that Use old folder picker was really off.
Changed setting to on but foobar2000 still couldn't see the USB stick.
(Just in case, tried different combinations of sticks and adapters).

Note that I'm looking under Internal Storage and foobar2000 music folder, since these are the only file browsing options available; am I wrong about this?

Peter
July 14th, 2017, 05:53 AM
Open settings ( great icon ) / Media Library

Add a folder (+)

You should be able to add your USB stick there.

We cannot implicitly show it because the system will not let us access the device without prior explicit user consent.

pastraga
July 14th, 2017, 06:30 AM
Understood, but still need guidance...
Running Android 7.0.

Add Folder doesn't show the stick in its folder list under Internal Storage.
Added /mnt to no avail.

ES File Explorer shows under Local a list:
[Home icon] Homepage
[Folders icon] Device
[Download icon] Download
[SD Card icon] 0 (Because I have no SD card inserted)
[USB icon] USB1002 (Will change to USB1003 and so on if I disconnect and reconnect)

In short: how to add the stick to the library?

pastraga
July 15th, 2017, 12:16 PM
Managed (not directly, but through an error message by Solid Explorer) to discover the mount point.
It's /mnt/media_rw/C0AE-BC1D in my case.
This is consistent with the information on https://forum.xda-developers.com/apps/mx-player/android-6-0-usb-otg-devices-t3285898.
Added that path to the Media Library Music folders, but "Access is denied" when I click it in Browse, while /mnt doesn't show media_rw.
Read that access to such folders require root access but maybe this isn't entirely precise since ES File Explorer can access it.
Source:
https://stackoverflow.com/questions/32201169/how-app-can-access-files-on-usb-otg-storages-in-android-6-0-api-level-23-witho.

Noted that (1.0.83) Advanced Settings doesn't have the folder picker choice anymore.

Still in need of a clue.

Peter
July 22nd, 2017, 08:58 AM
Sorry, cannot confirm /mnt/media_rw/XXXX-XXXX working on my Nexus 5X right now, all I get is "access denied", apparently the app needs root access for this, which is not an option for us.

As noted in the linked posts, Android's Storage Access Framework is required to access USB storage. We do support it but it's ridiculously slow to index media and hidden by default.
In order to add a folder via SAF, use "specify path manually", then "use system folder picker".

pastraga
July 22nd, 2017, 09:15 AM
Sorry, cannot confirm /mnt/media_rw/XXXX-XXXX working on my Nexus 5X right now, all I get is "access denied", apparently the app needs root access for this, which is not an option for us.

As noted in the linked posts, Android's Storage Access Framework is required to access USB storage. We do support it but it's ridiculously slow to index media and hidden by default.
In order to add a folder via SAF, use "specify path manually", then "use system folder picker".

Sure, but if I "Specify path manually" then "Launch system folder pick", the resulting list does not include the OTG drive, even though it's there.

Peter
July 25th, 2017, 05:37 AM
The system folder picker does list the USB OTG drives on all my testing devices.

If it doesn't for you, it's probably not even my fault, as it's a system component not something I wrote.

I'm sorry that I can't help much with this. Be advised that this is not worth the trouble - even if you get it working, media indexing will be crazy slow through Android's SAF.

Peter
July 25th, 2017, 05:38 AM
Re Windows Phone

From the next update I'm enabling "add any folder" in Media Library configuration so you'll can access your USB storage devices freely, I'll test USB storage with my own devices to be sure.

pastraga
July 25th, 2017, 06:27 AM
Understood.
Will use only the internal microSD.

For other users:
Be warned that Moto G5, running Android 7, has OTG support issues.

Peter
July 27th, 2017, 06:49 AM
On the Windows Phone subject again-

What device are you using and what brand of USB stick have you been able to access at all?

My test devices (640XL, 1020) don't recognize my USB sticks at all over OTG adapter.

However I've added relevant functionality to foobar2000 mobile so it should work... in theory. Expect major update early next week.

Peter
August 2nd, 2017, 11:43 AM
Relevant Windows Phone fb2k update - 1.0.88 - is out.

I was unable to confirm on my own devices as neither phone recognizes mass storage over OTG, but you can now add arbitrary folders to your music library as long as the system file picker can see them.

Peter
August 7th, 2017, 08:57 AM
Follow up on Android Storage Access Framework issues-

Update 1.0.89 is now available for beta testers. A rather nasty bug has been fixed; I've added some multi threading optimizations specially aiming to improve Android SAF performance.
USB OTG should be somewhat less painful to use now.