Skip to content
  • Hjem
  • Seneste
  • Etiketter
  • Populære
  • Verden
  • Bruger
  • Grupper
Temaer
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Kollaps
FARVEL BIG TECH
sknob@noblogo.orgS

sknob@noblogo.org

@sknob@noblogo.org
About
Indlæg
1
Emner
1
Fremhævelser
0
Grupper
0
Følgere
0
Følger
0

Vis Original

Indlæg

Seneste Bedste Controversial

  • sknob/music v5.3.1 Release Notes, mediaSession Edition!
    sknob@noblogo.orgS sknob@noblogo.org

    #blogpost #music #coding

    So, thanks to @limebar@mastodon.social and @scy@chaos.social who implemented this feature for TIBR and TIBtv, I discovered how to send metadata to the system media player when you play my music on my site (using the Media Session API).

    What this means is that you can now see the title, artist and artwork in your system player when you play a song on sknob.fr/music.

    It could have ended there, but that’s when things got out of hand... In the following image, you’ll notice you can’t skip to the previous or next track.

    Screen capture of the full-screen music player on an old version of iOS which shows the song title, artist and cover image currently playing (in this case, Ukulele Bonk)

    But it turns out you can handle these actions with the mediaSession API, provided you have your own functions to do the actual work.

    This revealed a different paradigm between what I had implemented on the site, and how a system media player works.

    • On my site, you could keep skipping tracks, including the last track of an album.
    • Whereas the mediaSession API sensibly assumes you have “go to the previous/next track” buttons, and if you are on the first or the last track of a playlist, well you can’t go back or forward, respectively.

    Which means that in the end, I had to:

    • Rethink my “skip” function as a “next track” function
    • Write a “previous track” function
    • Add a “previous track” button to my weird UI (and to my keyboard shortcuts (available in “about”)
    • Grey out and deactivate the previous and next buttons in my weird UI when there is no previous or next track (which is what took me the longest to figure out; funny how it’s often the simple things that trip you up)
    • Add the appropriate calls in the mediaSession function to go to the previous/next track, including code to grey out the previous/next buttons in the system player when there is no previous or next track
    • This all seemed to work everywhere it was supposed to, until I noticed that the play/pause button was disabled in the media player on my old iPhone 7! So I had to add the appropriate calls in the mediaSession function to call my play/pause function.

    Phew... I told you things got out of hand! All this probably deserves more than a 0.0.1 version bump...

    Hopefully, it’s all sorted out now. But before you complain, according to the spec, this is supported pretty much everywhere except in the Android WebView!

    Media player on the Mac: Mosaic of the Mac system player, showing the 4 tracks of my Cities EP with previous & next buttons, which are grayed out for the first and last track.)

    Greyed-out buttons in my UI and in the iPhone 7 media player:

    Mosaic of the same album in my UI, with the grayed out previous and next buttons, successively, plus a capture of the system media player on my old iPhone 7 showing the last track of the album, with a greyed out next button.

    Elsewhere: Music | Videos | Mastodon

    Ikke-kategoriseret coding blogpost music
  • Log ind

  • Har du ikke en konto? Tilmeld

  • Login or register to search.
Powered by NodeBB Contributors
Graciously hosted by data.coop
  • First post
    Last post
0
  • Hjem
  • Seneste
  • Etiketter
  • Populære
  • Verden
  • Bruger
  • Grupper