Friday, 20 September 2024

Improve iPad music

Intro

During the summer I am away more, often without access to wifi or internet.
It is convenient and enjoyable to listen to local music on iPad using the Apple Music app.
However it is inconvenient to update my iPad music by connecting to my PC and using iTunes to add/remove music.
The consequence is that my iPad music is often outdated; it contains albums I don't really listen to and doesn't include current favourites.

Ideas

Apple Music
Apple Photos works well with iCloud, allowing you to look at shared pictures on a range of devices.  I hoped Apple Music might provide similar functionality but it will only sync music if you have an Apple Music subscription (£11 pcm).

iCloud
iCloud looked like it could be part of the solution.  Files can be moved to and from iCloud using iCloud Drive on Windows, Apple Files on iPad or a browser to access iCloud.com.  Free storage is limited to 5GB but 50GB can be added for £1 pcm.
When  you access an iCloud folder your view is synced so all users see the same set of files.  Unfortunately this feature does not include the capability to physically synchronise copies of file onto the local device.  You still need an internet connection to access the files.

Files
Apple Files can access music on the local drive, iCloud or a network share.
Double-clicking on a music file causes it to play within the Files app.
This is interesting but not a practical solution, unless playlists can also be started within Files (I didn't investigate).

VLC
VLC is able to play music directly from iCloud but it would still require an internet connection.

Doppler

A reddit post I saw mentioned that a music player app called Doppler may help with my requirement.  After trying out its features I invested £9 in purchasing it.

Like many music player apps Doppler has a music library.  You can import music to this library from a variety of sources.  I particularly liked the help text Doppler provided explaining various download methods.  Music can be imported from, for example:

1)    local hard drive
2)    iCloud
3)    network share
4)    Apple 
Music storage

This functionality provides a solution to my requirements.
I started off by importing all the albums from my Apple Music
I then select any new albums I want from my PIP Music database.
As albums are easy to download I can remove ones I don't listen to much and re-add them later if my mood / tastes change.
Once albums are imported I can listen to them without wifi or internet access.
I don't need to use iTunes or even iCloud to make this work

The screen shot below shows the Apple files app which is accessing the pipmusic folders on my PIP NAS.  I can select an album the "share" it with Doppler to add it in.

As I can access PIP if my iPad is connected to  wireguardVPN, I dont even need to be at home to add music to the iPad.

Xcode

 Intro

I have been thinking about potential approaches to, and uses for, executing programs on the iPad.  I previously investigated, briefly, the idea of running a webserver on my iPad. Although the idea seems good, I wasn't convinced a webserver provides a good environment.

The preferred Apple route for iPad programming is actually to develop a cross-platform app using the Apple Xcode IDE running on my macBook and to deploy the completed application to the iPad. Apple are restrictive regarding installing iPad apps and this approach avoids such issues.

Installation

Xcode is a large, free application (6GB or more) which provides a range of languages to write programs for different Apple devices.  It can be installed to a macbook from the app store. I included the IOS components as my target environment is an iPad.

macBook PoC

My preferred programming language is C and I found a simple tutorial to get started with C in Xcode. I created a command line project within Xcode and it gave me a skeleton "Hello World" program as a template.  It is easy to build and run this within the IDE, giving output at the bottom of the screen.

You can then run the C executable generated on a macBook terminal session.


IOS PoC

Next I want an app which will run on the iPad.

I found a couple of youtube tutorials to guide me through the process.  The first one, from CodewithChris , provides a detailed intro to the IDE.

The second from IOS Academy goes into less detail and provides a nice simple emoji display app - I followed this tutorial mainly.

Both the tutorials use the SWIFT interface and the SWIFT programming language, which is very powerful and is preferred for Apple development.
An alternative is to use the older Storyboard interface and SWIFT or Objective-C programming language.

Selecting IOS app in the new Project dialog and choosing the SWIFT interface I was presented with a draft hello world app.  I could build and run this app in the built-in simulator to get an idea of how the app will look on an iPhone/iPad.



I followed the IOS Academy tutorial to create a simple app "EmojiLover".  It allows you to choose from a selection of icons and display on the screen.

The code is explained very well to give some understanding of programming using the Swift language.  SWIFT is a powerful Object Orientated language, and it would take a concerted effort to become fluent in it.

There are some interesting features, notably including Emojis as pictures in the code.  The rest of the code is pretty incomprehensible without understanding the objects making up the User Interface and Program.

The result is very good.  You can see a preview of the code whilst programming and can periodically run the simulator to see how it will look on the device.


IOS Download

The IOS Academy tutorial didn't cover testing the app on an iPad/iPhone so I looked at CodeWithChris.

The first step is to connect the iPad and macBook.  My usb-c  to lightning cable didn't appear to work (no device was seen by macBook) so I  purchased a new usb-c adapter cable which worked a treat.

There were a few compatibility / security issues to resolve before the iPad and macBook were working together:
1) My Xcode environment had to be set for IOS16 to match the iPad
2) I had to enable Developer mode on my iPad
3) In iCloud I had to setup a Personal Account and keychain for the macbook to access the iPad.
4) On the ipad I had to allow user j200@helliwell.org on macbook access to the iPad.

Once macBook and iPad were happily communicating I could tell Xcode to build the app for my iPad and after a slight delay the iPad shows my completed app 😀😀😀


At this stage you can disconnect the iPad from macBook.  An icon is created on the iPad home page which you can use to run the app again.

Unfortunately, unless you have an Apple Developer license ($100pa) Apple only allow you to use it for a week - then you have to reinstall.  This negates the purpose of using Xcode so I wont progress further.😭