This project offers a port of MediaRouteActionProvider
, and its support
classes, to work with
native API Level 11+ fragments and the action bar. These were ported
from the mediarouter
Android library project, where these classes
require the appcompat
action bar and, hence, the fragment backport.
The sincere hope is that Google will ship an equivalent to this someday, at which point in time this library will be deprecated.
This Android library project is available as a JAR.
This project is also available as
an artifact for use with Gradle. To use that, add the following
blocks to your build.gradle
file:
repositories {
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
dependencies {
compile 'com.commonsware.cwac:mediarouter:0.1.0'
}
Or, if you cannot use SSL, use http://repo.commonsware.com
for the repository
URL.
Note that this library contains a copy of the support-v4
JAR in its
libs/
. This is presently required to keep project-level compatibility between
Eclipse and Gradle. This will hopefully be addressed in a future version of
this library.
You use this the same as you would use the official mediarouter
edition, with
the following changes:
-
Use
Activity
instead ofActionBarActivity
. -
Use the native API Level 11 version of fragments, rather than the Android Support package's backport.
-
You do not need (or want) a theme based on
Theme.AppCompat
, but rather can use ordinary themes (e.g.,Theme.Holo.Light.DarkActionBar
). -
Your menu resources and such will need to reference
com.commonsware.cwac.mediarouter.MediaRouteActionProvider
rather thanandroid.support.v7.app.MediaRouteActionProvider
. Menu resources should also use the regularandroid:actionProviderClass
attribute for specifying this class, rather than the alternative required byappcompat
(e.g.,app:actionProviderClass
). -
Your import for
MediaRouteActionProvider
will need to change to the aforementioned class. Most otherandroid.support.v7
imports will remain as-is, particularlyMediaRouter
itself. If you are using an IDE that supports bulk import resolution (e.g., Eclipse with Ctrl-Shift-O), you might consider deleting allandroid.support.v7
imports and let the IDE help you grab thecom.commonsware.cwac.mediarouter
ones where needed.
This project depends upon the mediarouter
library project, because it still
references classes from there, particularly MediaRouter
itself. That, in turn,
will require appcompat
. However, your code will not need to use appcompat
,
and ProGuard should strip a lot of the junk out.
The minimum supported SDK for this library is API Level 14. If you want to support
older devices, you should be using appcompat
and the fragments backport anyway.
This is version v0.1.0 of this module, meaning it is a wee bit more than a proof of concept, but not by all that much.
There are two sample projects, demo/
and demo-remoteplayback/
, that illustrate
the use of this library. The first one just shows the MediaRouteActionProvider
and
shows you the route when it changes. The second one demonstrates the currently-flaky
RemotePlaybackClient
class, for playing back media on a device like a Chromecast.
The code in this project is licensed under the Apache Software License 2.0, per the terms of the included LICENSE file. Most of the library's code is licensed this way by Google; the changes made to that code to implement the port are licensed this way by CommonsWare.
If you have questions regarding the use of this code, please post a question
on StackOverflow tagged with commonsware
and android
. Be sure to indicate
what CWAC module you are having issues with, and be sure to include source code
and stack traces if you are encountering crashes.
If you have encountered what is clearly a bug, or if you have a feature request, please post an issue. Be certain to include complete steps for reproducing the issue.
Do not ask for help via Twitter.
Also, if you plan on hacking on the code with an eye for contributing something back, please open an issue that we can use for discussing implementation details. Just lobbing a pull request over the fence may work, but it may not.
- v0.1.0: initial release