Skip to content

Add snippets for the basic media player app guide - #1116

Closed
edward-williams-stellarelements wants to merge 4 commits into
android:mainfrom
StellarElements:media-playback-app
Closed

edward-williams-stellarelements wants to merge 4 commits into
android:mainfrom
StellarElements:media-playback-app

Conversation

@edward-williams-stellarelements

Copy link
Copy Markdown

Snippets for the "Create a basic media player app using Media3 ExoPlayer" guide,
https://developer.android.com/media/implement/playback-app, with region tags, in the media module.

Kat reviewed these on our fork, StellarElements#7. The first commit is hers,
preserved from the extraction branch.

Things that are not a straight copy of the page:

The playback_service block publishes five lines the page's block does not show, the onGetSession
override and its comment. Tagging onGetSession where it sits puts it inside the playback_service
region as well, because a region tag opened inside a [START_EXCLUDE] renders as an empty snippet. The
block under "Implementing a MediaSessionService" needs those five lines added to match.

ktlint reindented the connect_ui block, eleven lines, indentation only. The page's block runs 2, 4, 6,
8 and 10 spaces, including a stray "},", and ktlint normalises it to 4-space.

media/build.gradle.kts gains media3-session and media3-ui. Needed to compile, and it matches what the
page tells readers to add under "Getting started" and "Managing playback with a media session".

Not migrated: the Gradle dependency blocks and the Java variants. The two AndroidManifest.xml blocks
are left out as well. The page writes android:name=".PlaybackService" while the class lives in
com.example.media, so a faithful copy would need the qualified name and would stop matching the page.
Separately, since API 34 a mediaPlayback foreground service also needs
FOREGROUND_SERVICE_MEDIA_PLAYBACK, which the block does not request. Both are page corrections and
have been passed on.

kkuan2011 and others added 3 commits September 17, 2026 18:37
The copy inside the exclude was missing the comment the page prints on
the tagged copy. Both copies are the same function, so neither should
read as the authoritative one.
Addresses Kat's review on #7.

- The file moves from misc to the media module Erik added, which also
  removes the duplicate android_media_playback_app_create_exoplayer tag
  that existed in both places.
- SessionCallbackService is gone. The on_get_session tags now sit around
  onGetSession inside PlaybackService, which means the exclude that hid
  it had to go: a region tag opened inside an exclude renders empty.
- media3-session and media3-ui move from misc to media with the code.
@edward-williams-stellarelements
edward-williams-stellarelements marked this pull request as ready for review September 17, 2026 22:53
@snippet-bot

snippet-bot Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@edward-williams-stellarelements

Copy link
Copy Markdown
Author

Closing as a duplicate: this work is already covered by #1115, which adds the same playback-app region tags to PlaybackApp.kt (create_media_session, playback_service, on_get_session, connect_ui) as part of the Media I migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants