Skip to content

Commit

Permalink
Update CCL to latest version
Browse files Browse the repository at this point in the history
1. Update CCL to latest version
2. Upgrade to google-play-services 8.3.0
3. Upgrade to support library version 23.1.1
   Issue #50 on github
4. Fix a few lint errors in resources.

Change-Id: Iaac3f0b72b27757e63cb428f8747dec7f5b0bdb8
  • Loading branch information
nageshs committed Nov 24, 2015
1 parent d3b0e9d commit ecfa619
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 17 deletions.
14 changes: 7 additions & 7 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ repositories {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-cast:7.8.0'
compile 'com.google.android.gms:play-services-cast:8.3.0'
compile 'com.google.android.support:wearable:1.2.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:mediarouter-v7:23.0.1'
compile 'com.android.support:leanback-v17:23.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:leanback-v17:23.1.1'

compile (name:'CastCompanionLibrary-debug', ext:'aar')
compile (name:'CastCompanionLibrary-debug-2.6.1', ext:'aar')
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
}
Binary file added mobile/libs/CastCompanionLibrary-debug-2.6.1.aar
Binary file not shown.
Binary file removed mobile/libs/CastCompanionLibrary-debug.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public int getCurrentStreamPosition() {
return mCurrentPosition;
}
try {
return (int)mCastManager.getCurrentMediaPosition();
return (int) mCastManager.getCurrentMediaPosition();
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LogHelper.e(TAG, e, "Exception getting media position");
}
Expand All @@ -113,6 +113,11 @@ public void setCurrentStreamPosition(int pos) {
this.mCurrentPosition = pos;
}

@Override
public void updateLastKnownStreamPosition() {
mCurrentPosition = getCurrentStreamPosition();
}

@Override
public void play(QueueItem item) {
try {
Expand Down Expand Up @@ -283,7 +288,7 @@ private void updateMetadata() {
if (mCallback != null) {
mCallback.onMetadataChanged(remoteMediaId);
}
mCurrentPosition = getCurrentStreamPosition();
updateLastKnownStreamPosition();
}
}
} catch (TransientNetworkDisconnectionException | NoConnectionException | JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ public int getCurrentStreamPosition() {
mMediaPlayer.getCurrentPosition() : mCurrentPosition;
}

@Override
public void updateLastKnownStreamPosition() {
if (mMediaPlayer != null) {
mCurrentPosition = mMediaPlayer.getCurrentPosition();
}
}

@Override
public void play(QueueItem item) {
mPlayOnFocusGain = true;
Expand Down
11 changes: 10 additions & 1 deletion mobile/src/main/java/com/example/android/uamp/MusicService.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ public void onApplicationConnected(ApplicationMetadata appMetadata, String sessi
switchToPlayer(playback, true);
}

@Override
public void onDisconnectionReason(int reason) {
LogHelper.d(TAG, "onDisconnectionReason");
// This is our final chance to update the underlying stream position
// In onDisconnected(), the underlying CastPlayback#mVideoCastConsumer
// is disconnected and hence we update our local value of stream position
// to the latest position.
mPlayback.updateLastKnownStreamPosition();
}

@Override
public void onDisconnected() {
LogHelper.d(TAG, "onDisconnected");
Expand Down Expand Up @@ -848,7 +858,6 @@ private void switchToPlayer(Playback playback, boolean resumePlaying) {
int oldState = mPlayback.getState();
int pos = mPlayback.getCurrentStreamPosition();
String currentMediaId = mPlayback.getCurrentMediaId();
LogHelper.d(TAG, "Current position from " + playback + " is ", pos);
mPlayback.stop(false);
playback.setCallback(this);
playback.setCurrentStreamPosition(pos < 0 ? 0 : pos);
Expand Down
5 changes: 5 additions & 0 deletions mobile/src/main/java/com/example/android/uamp/Playback.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public interface Playback {
*/
void setCurrentStreamPosition(int pos);

/**
* Query the underlying stream and update the internal last known stream position.
*/
void updateLastKnownStreamPosition();

/**
* @param item to play
*/
Expand Down
9 changes: 4 additions & 5 deletions mobile/src/main/res/layout/tv_playback_controls.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,11 +16,11 @@

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.example.android.uamp.ui.tv.TvPlaybackFragment"
<fragment
android:id="@+id/playback_controls_fragment"
android:name="com.example.android.uamp.ui.tv.TvPlaybackFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Expand Down
4 changes: 2 additions & 2 deletions mobile/src/main/res/layout/tv_vertical_grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.example.android.uamp.ui.tv.TvVerticalGridFragment"
<fragment
android:id="@+id/vertical_grid_fragment"
android:name="com.example.android.uamp.ui.tv.TvVerticalGridFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

0 comments on commit ecfa619

Please sign in to comment.