Skip to content

Commit 1259da8

Browse files
author
Chris Bellew
committed
Version 2.0.1. Added support for displaying fan art slideshow on Chromecast. Use proper method of disconnecting from Chromecast.
1 parent 000e891 commit 1259da8

File tree

8 files changed

+50
-17
lines changed

8 files changed

+50
-17
lines changed

VoiceControlForPlex.iml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
</facet>
99
</component>
1010
<component name="NewModuleRootManager" inherit-compiler-output="true">
11-
<output url="file://$MODULE_DIR$/build/classes/main" />
12-
<output-test url="file://$MODULE_DIR$/build/classes/test" />
1311
<exclude-output />
1412
<content url="file://$MODULE_DIR$">
1513
<excludeFolder url="file://$MODULE_DIR$/.gradle" />

mobile/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.atomjack.vcfp"
5-
android:versionCode="38"
6-
android:versionName="2.0" >
5+
android:versionCode="39"
6+
android:versionName="2.0.1" >
77

88
<uses-permission android:name="com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API" />
99
<uses-permission android:name="android.permission.INTERNET" />

mobile/src/main/java/com/atomjack/vcfp/CastPlayerManager.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.atomjack.vcfp.model.Connection;
1111
import com.atomjack.vcfp.model.PlexClient;
1212
import com.atomjack.vcfp.model.PlexMedia;
13+
import com.atomjack.vcfp.model.PlexServer;
1314
import com.atomjack.vcfp.model.PlexTrack;
1415
import com.atomjack.vcfp.model.PlexVideo;
1516
import com.google.android.gms.cast.ApplicationMetadata;
@@ -19,6 +20,7 @@
1920

2021
import java.util.ArrayList;
2122
import java.util.List;
23+
import java.util.concurrent.ConcurrentHashMap;
2224

2325
public class CastPlayerManager {
2426
private PlexMedia nowPlayingMedia;
@@ -66,6 +68,9 @@ public static final class PARAMS {
6668
public static final String PLEX_USERNAME = "plexUsername";
6769
public static final String ACCESS_TOKEN = "accessToken";
6870

71+
public static final String RECEIVE_SERVERS = "receiveServers";
72+
public static final String SERVERS = "servers";
73+
6974
};
7075

7176
private Context mContext;
@@ -98,14 +103,33 @@ public void subscribe(final PlexClient _client) {
98103
if(castManager.isConnected()) {
99104
castManager.disconnect();
100105
}
101-
castManager.setDevice(_client.castDevice, false);
106+
castManager.setDevice(_client.castDevice);
102107
castConsumer.setOnConnected(new Runnable() {
103108
@Override
104109
public void run() {
105110
mClient = _client;
106111
// currentState = castManager.getPlaybackStatus();
107112
Logger.d("castConsumer connected to %s", mClient.name);
108113
getPlaybackState();
114+
115+
//
116+
JSONObject obj = new JSONObject();
117+
try {
118+
obj.put(PARAMS.ACTION, PARAMS.RECEIVE_SERVERS);
119+
120+
PlexServer server = VoiceControlForPlexApplication.gsonRead.fromJson(VoiceControlForPlexApplication.getInstance().prefs.get(Preferences.SERVER, ""), PlexServer.class);
121+
if(server.name.equals(mContext.getString(R.string.scan_all)))
122+
obj.put(PARAMS.SERVERS, VoiceControlForPlexApplication.gsonWrite.toJson(VoiceControlForPlexApplication.getInstance().servers));
123+
else {
124+
ConcurrentHashMap<String, PlexServer> map = new ConcurrentHashMap<String, PlexServer>();
125+
map.put(server.name, server);
126+
obj.put(PARAMS.SERVERS, VoiceControlForPlexApplication.gsonWrite.toJson(map));
127+
}
128+
sendMessage(obj);
129+
} catch (Exception ex) {}
130+
131+
132+
109133
subscribed = true;
110134
if(listener != null)
111135
listener.onCastConnected(_client);
@@ -116,18 +140,21 @@ public void run() {
116140
}
117141

118142
public boolean isSubscribed() {
143+
Logger.d("[CastPlayerManager] subscribed: %s, mClient: %s", subscribed, mClient);
119144
return subscribed && mClient != null;
120145
}
121146

122147
public void unsubscribe() {
123148
try {
124149
Logger.d("is connected: %s", castManager.isConnected());
125-
if(castManager.isConnected())
126-
castManager.stopApplication();
150+
if(castManager.isConnected()) {
151+
castManager.disconnect();
152+
}
127153
} catch (Exception ex) {
128154
ex.printStackTrace();
129155
}
130156
subscribed = false;
157+
mClient = null;
131158
if(listener != null)
132159
listener.onCastDisconnected();
133160
}
@@ -257,8 +284,8 @@ private static VideoCastManager getCastManager(Context context) {
257284
VideoCastManager.FEATURE_DEBUGGING);
258285

259286
}
260-
castManager.setContext(context);
261-
castManager.setStopOnDisconnect(false);
287+
// castManager.setContext(context);
288+
castManager.setStopOnDisconnect(true);
262289
return castManager;
263290
}
264291

mobile/src/main/java/com/atomjack/vcfp/VoiceControlForPlexApplication.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@ public static void addPlexServer(PlexServer addedServer, final Runnable onFinish
227227
}
228228
PlexServer serverToAdd = null;
229229
// First, see if we've already found this server from a remote scan. We'll want to use that one instead so the remote connections are included
230-
for(PlexServer _server : VoiceControlForPlexApplication.servers.values()) {
231-
if(_server.machineIdentifier.equals(addedServer.machineIdentifier)) {
232-
serverToAdd = _server;
233-
break;
230+
if(onFinish == null) { // onFinish is null when called from a local server scan - otherwise it's from a remote scan
231+
for (PlexServer _server : VoiceControlForPlexApplication.servers.values()) {
232+
if (_server.machineIdentifier.equals(addedServer.machineIdentifier)) {
233+
serverToAdd = _server;
234+
break;
235+
}
234236
}
235237
}
236238
final PlexServer server = serverToAdd == null ? addedServer : serverToAdd;

mobile/src/main/java/com/atomjack/vcfp/activities/VCFPActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ public void onTimelineReceived(MediaContainer mc) {
593593

594594
@Override
595595
public void onUnsubscribed() {
596-
Logger.d("VCFPActivity onUnsubscribed");
596+
Logger.d("[VCFPActivity] onUnsubscribed");
597597
setCastIconInactive();
598598
nowPlayingMedia = null;
599599
VoiceControlForPlexApplication.getInstance().cancelNotification();

mobile/src/main/res/xml/changelog.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<changelog>
3+
<release version="2.0.1" versioncode="39">
4+
<change>Added Android Wear Support.</change>
5+
<change>Consolidated Server/Client scanning, which will run smoother.</change>
6+
<change>Plex Server Connections will now expire an hour after discovery. This allows using a local server then moving to another location and accessing that server remotely (previously, you'd have to scan for servers again so that the remote connection would be used instead of local).</change>
7+
<change>Support for displaying fan art slideshow on Chromecast.</change>
8+
<change>Various bug fixes and enhancements.</change>
9+
</release>
310
<release version="2.0" versioncode="38">
411
<change>Added Android Wear Support.</change>
512
<change>Consolidated Server/Client scanning, which will run smoother.</change>

wear/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.atomjack.vcfp"
4-
android:versionCode="38"
5-
android:versionName="2.0">
4+
android:versionCode="39"
5+
android:versionName="2.0.1">
66

77
<uses-feature android:name="android.hardware.type.watch" />
88

wear/wear.iml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
8282
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
84-
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8584
</content>
8685
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
8786
<orderEntry type="sourceFolder" forTests="false" />

0 commit comments

Comments
 (0)