Git Product home page Git Product logo

android-media-controller's Introduction

Media Controller Test

Create a simple MediaController that connects to a MediaBrowserService in order to test inter-app media controls. This tool is described in the Android documentation: Using the media controller test app.

This app works with the Universal Android Music Player sample, or any other app that implements the media APIs. https://github.com/googlesamples/android-UniversalMusicPlayer

Usage

  1. Select an app from the list of those presented.
    • Only apps that register a service with an intent filter action of "android.media.browse.MediaBrowserService" will be shown.
  2. Select the type of action to perform to start the player. Options are:
    • Search: Sends the text provided as a search via prepareFromSearch() or playFromSearch().
    • Media ID: Sends the text provided as a media ID via prepareFromMediaId() or playFromMediaId().
    • URI: Sends the text provided as a URI via prepareFromUri() or playFromUri().
    • No Input: Calls the methods prepare() or play() directly.
  3. Text below the PREPARE and PLAY buttons updates based on changes to the media player state via onPlaybackStateChanged and onMetadataChanged and includes the current player state reported via PlaybackStateCompat.getState().
  4. Swipe to the left to see typical media controls with the media's art as a background, if provided.
  5. Press back to return to the list of media apps.

Via ADB

It's also possible to launch the app via ADB and the Activity manager (am).

Parameter Extra Name
Package name com.example.android.mediacontroller.PACKAGE_NAME
Search term com.example.android.mediacontroller.SEARCH
Media ID com.example.android.mediacontroller.MEDIA_ID
URI com.example.android.mediacontroller.URI

To start the app and connect to UAMP:

adb shell am start -n com.example.android.mediacontroller/.LaunchActivity --es com.example.android.mediacontroller.PACKAGE_NAME "com.example.android.uamp"

To perform a search with the term "jazz?" one would use:

adb shell am start -n com.example.android.mediacontroller/.MediaAppControllerActivity --es com.example.android.mediacontroller.SEARCH "jazz?"

Verification

Audio Focus

This app allows for testing how media apps respond to audio focus changes.

The app allows requesting and abandoning the following types of audio focus:

  • AUDIOFOCUS_GAIN
  • AUDIOFOCUS_GAIN_TRANSIENT
  • AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK

For more information on audio focus please see Managing Audio Focus.

Supported Actions

This tool displays the supported actions as reported by the MediaSession in the call to MediaSessionCompat.setPlaybackState() as a list of prepare and play actions on the main screen. For actions that are not declared as supported, it also colors the buttons red on the controller screen.

See the screenshots below for examples.

Screenshots

License

Copyright 2017 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

android-media-controller's People

Contributors

cartland avatar cwei789 avatar dpreussler avatar flyktsodan avatar friederbluemle avatar jinpark6 avatar julioz avatar leo-neat avatar marcbaechinger avatar morckx avatar nic0lette avatar rasekh avatar robroseknows avatar romanofranz avatar rumburake avatar sigmanzero avatar soumya92 avatar yschimke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-media-controller's Issues

Bug: Can not give a query to "Play From Search Test"

Description

In the class TestDescriptor the playFromSearch in line 39 sets queryRequired to false.
Therefore, the query is never shown in the configuration dialog, the dialog only adds EditText fields for tests with this field set to true

How to reproduce

  • Install current version of the Media Controller Tester app
  • Test any app that declares "PLAY_FROM_SEARCH" support
  • Go to test suites, run either basic tests or auto tests -> "Play from Search Test" fails (if the app doesn't play anything from an empty search query

Expected behaviour

The test result card says

Enter the search query in the query field

So that's what I would expect, to be able to enter that. Furthermore, one might argue that an app should get a passing grade when the search query is empty and the player ends up in either the starting state or any other state than "error"

Devices, OS

All

Unexpected Test Result: "Initial Playback State" is tested way late

Description

In the commonTests of the auto test suite, there is the initialPlaybackStateTest at line 298ff. in TestDescriptor
It has the ID 15, and is therefore executed as one of the last tests that there are, way after for instance "skip to next" or "play".
This can lead to the test failing, even though the intention of the test is fulfilled (i.e. the state of the app at the very beginning is STATE_NONE or any other of the allowed states)

How to reproduce

  • Install current version of the Media Controller Tester app
  • Test any app that plays media when skipping to next
  • Run the auto test suite

Expected behaviour

The test should be started first, it should be given the id -1

Devices, OS

All

Media Artwork Test does not allow https Uri

The test mentioned above expects only content or android.resource URI.
But remote Uri are working fine and handled by Android Auto, Assistant Driving Mode correctly. Could not find any documentation either that this is not allowed.

Scripting the tests

Hi :)
Is there a way to run the tests through gradle, in order to use them in a CI environment?

Doesn't compile with targeting SDK 30+

This sample application needs updating. you can't submit apps built for 29 to playstore anymore. when I update the build script to target 30, it stops working.

crash on test when using Parcelable in the PlaybackState

the app crashes when trying to print a bundle that contains Parcelables from the other app as they cant be loaded

07-29 13:49:02.056 26327 26327 E Parcel  : Class not found when unmarshalling: com.xxx.yyy.zzz.TrackSourceInfo
07-29 13:49:02.056 26327 26327 E Parcel  : java.lang.ClassNotFoundException: com.xxx.yyy.zzz.TrackSourceInfo
07-29 13:49:02.056 26327 26327 E Parcel  : 	at java.lang.Class.classForName(Native Method)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at java.lang.Class.forName(Class.java:454)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Parcel.readParcelableCreator(Parcel.java:3338)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Parcel.readParcelable(Parcel.java:3272)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Parcel.readValue(Parcel.java:3174)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Parcel.readArrayMapInternal(Parcel.java:3567)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.BaseBundle.unparcel(BaseBundle.java:236)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.BaseBundle.keySet(BaseBundle.java:569)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at com.example.android.mediacontroller.TestUtilsKt.formatPlaybackStateExtras(TestUtils.kt:229)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at com.example.android.mediacontroller.TestUtilsKt.formatPlaybackState(TestUtils.kt:269)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at com.example.android.mediacontroller.MediaAppTestingActivity$controllerCallback$1.onPlaybackStateChanged(MediaAppTestingActivity.kt:1127)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.support.v4.media.session.MediaControllerCompat$Callback$MessageHandler.handleMessage(MediaControllerCompat.java:1084)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Handler.dispatchMessage(Handler.java:106)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.os.Looper.loop(Looper.java:223)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at android.app.ActivityThread.main(ActivityThread.java:7664)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at java.lang.reflect.Method.invoke(Native Method)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
07-29 13:49:02.056 26327 26327 E Parcel  : 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

crash on Android versions older than 7.0

I wanted to test my media app on a Marshmallow device, but MCT crashes, because feature check loop uses streams which is unsupported before API 24.

Screenshot 2021-02-15 211751

We should use a simple Java loop to keep MCT working on Android 5 and 6 until the file is converted to Kotlin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.