Skip to content

Commit 7715553

Browse files
author
Chris Bellew
committed
[Chromecast] Fixed next/previous track buttons.
Fixed vertical alignment of controls on now playing screens.
1 parent aefee24 commit 7715553

File tree

6 files changed

+54
-18
lines changed

6 files changed

+54
-18
lines changed

Voice Control For Plex/src/main/java/com/atomjack/vcfp/CastPlayerManager.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static final class PARAMS {
5555
public static final String ACTION_STOP = "stop";
5656
public static final String ACTION_SEEK = "seek";
5757
public static final String ACTION_GET_PLAYBACK_STATE = "getPlaybackState";
58+
public static final String ACTION_NEXT = "next";
59+
public static final String ACTION_PREV = "prev";
5860

5961
public static final String PLEX_USERNAME = "plexUsername";
6062

@@ -114,7 +116,8 @@ public boolean isSubscribed() {
114116
public void unsubscribe() {
115117
try {
116118
Logger.d("is connected: %s", castManager.isConnected());
117-
castManager.stopApplication();
119+
if(castManager.isConnected())
120+
castManager.stopApplication();
118121
} catch (Exception ex) {
119122
ex.printStackTrace();
120123
}
@@ -178,6 +181,26 @@ public void seekTo(int seconds) {
178181

179182
}
180183

184+
public void doNext() {
185+
JSONObject obj = new JSONObject();
186+
try {
187+
obj.put(PARAMS.ACTION, PARAMS.ACTION_NEXT);
188+
sendMessage(obj);
189+
} catch (Exception ex) {
190+
ex.printStackTrace();
191+
}
192+
}
193+
194+
public void doPrevious() {
195+
JSONObject obj = new JSONObject();
196+
try {
197+
obj.put(PARAMS.ACTION, PARAMS.ACTION_PREV);
198+
sendMessage(obj);
199+
} catch (Exception ex) {
200+
ex.printStackTrace();
201+
}
202+
}
203+
181204
private void sendMessage(String action) {
182205
JSONObject message = new JSONObject();
183206
try {

Voice Control For Plex/src/main/java/com/atomjack/vcfp/PlexSubscription.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ public void run() {
321321
Logger.d("PlexSubscription onSubscribed, client: %s, listener: %s", mClient, listener);
322322
if (listener != null && mClient != null) {
323323
listener.onSubscribed(mClient);
324-
// Logger.d("Sending broadcast");
325-
// Intent subscribedBroadcast = new Intent(ACTION_SUBSCRIBED);
326-
// subscribedBroadcast.putExtra(EXTRA_CLIENT, mClient);
327-
// LocalBroadcastManager.getInstance(listener).sendBroadcast(subscribedBroadcast);
328324
}
329325
}
330326
});

Voice Control For Plex/src/main/java/com/atomjack/vcfp/activities/CastActivity.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.atomjack.vcfp.model.PlexMedia;
2121
import com.google.sample.castcompanionlibrary.cast.VideoCastManager;
2222

23-
import java.util.ArrayList;
2423
import java.util.Arrays;
2524
import java.util.List;
2625

@@ -145,8 +144,8 @@ private void hideConnectingDialog() {
145144
}
146145

147146
private void beginPlayback() {
148-
String url = castPlayerManager.getTranscodeUrl(nowPlayingMedia);
149-
Logger.d("url: %s", url);
147+
// String url = castPlayerManager.getTranscodeUrl(nowPlayingMedia);
148+
// Logger.d("url: %s", url);
150149
Logger.d("duration: %s", nowPlayingMedia.duration);
151150

152151
Logger.d("offset is %d", getOffset(nowPlayingMedia));
@@ -262,6 +261,16 @@ public void doStop(View v) {
262261
}
263262
}
264263

264+
public void doNext(View v) {
265+
Logger.d("doNext");
266+
castPlayerManager.doNext();
267+
}
268+
269+
public void doPrevious(View v) {
270+
Logger.d("doPrevious");
271+
castPlayerManager.doPrevious();
272+
}
273+
265274
@Override
266275
public void onStopTrackingTouch(SeekBar _seekBar) {
267276
Logger.d("stopped changing progress: %d", _seekBar.getProgress());

Voice Control For Plex/src/main/java/com/atomjack/vcfp/activities/NowPlayingActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ protected void onCreate(Bundle savedInstanceState) {
4646
Logger.d("found saved instance state");
4747
nowPlayingMedia = savedInstanceState.getParcelable(VoiceControlForPlexApplication.Intent.EXTRA_MEDIA);
4848
mClient = savedInstanceState.getParcelable(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT);
49-
Logger.d("[NowPlaying] set mClient: %s", mClient);
49+
Logger.d("[NowPlaying] set client: %s", mClient);
5050
} else {
5151
nowPlayingMedia = getIntent().getParcelableExtra(VoiceControlForPlexApplication.Intent.EXTRA_MEDIA);
5252
mClient = getIntent().getParcelableExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT);
53-
Logger.d("[NowPlayingActivity] 2 set mClient: %s", mClient);
53+
Logger.d("[NowPlayingActivity] 2 set client: %s", mClient);
5454
}
5555

5656
if(mClient == null || nowPlayingMedia == null)

Voice Control For Plex/src/main/res/layout/playback.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
android:gravity="center_vertical"
1414
android:maxLines="1"
1515
android:layout_weight="1"
16-
android:paddingLeft="15sp" />
16+
android:paddingLeft="15sp"
17+
android:layout_marginTop="10dp"/>
1718
<ImageButton
1819
android:layout_width="0dp"
1920
android:layout_height="wrap_content"
@@ -60,5 +61,6 @@
6061
android:text="00:00"
6162
android:id="@+id/durationView"
6263
android:maxLines="1"
63-
android:layout_weight="1" />
64+
android:layout_weight="1"
65+
android:layout_marginTop="10dp"/>
6466
</LinearLayout>

Voice Control For Plex/src/main/res/layout/playback_music.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,40 @@
1313
android:gravity="center_vertical"
1414
android:maxLines="1"
1515
android:layout_weight="1"
16-
android:paddingLeft="15sp" />
16+
android:paddingLeft="15sp"
17+
android:layout_marginTop="10dp"/>
1718
<ImageButton
1819
android:layout_width="0dp"
1920
android:layout_height="wrap_content"
2021
android:background="@android:color/transparent"
2122
android:onClick="doPrevious"
2223
android:id="@+id/rewindButton" android:src="@drawable/button_previous"
23-
android:layout_weight="1" />
24+
android:layout_weight="1"
25+
android:layout_marginTop="10dp"/>
2426
<ImageButton
2527
android:layout_width="0dp"
2628
android:layout_height="wrap_content"
2729
android:background="@android:color/transparent"
2830
android:onClick="doPlayPause"
2931
android:id="@+id/playPauseButton" android:src="@drawable/button_play"
30-
android:layout_weight="1" />
32+
android:layout_weight="1"
33+
android:layout_marginTop="10dp"/>
3134
<ImageButton
3235
android:layout_width="0dp"
3336
android:layout_height="wrap_content"
3437
android:background="@android:color/transparent"
3538
android:onClick="doStop"
3639
android:id="@+id/stopButton" android:src="@drawable/button_stop"
37-
android:layout_weight="1" />
40+
android:layout_weight="1"
41+
android:layout_marginTop="10dp"/>
3842
<ImageButton
3943
android:layout_width="0dp"
4044
android:layout_height="wrap_content"
4145
android:background="@android:color/transparent"
4246
android:onClick="doNext"
4347
android:id="@+id/forwardButton" android:src="@drawable/button_next"
44-
android:layout_weight="1" />
48+
android:layout_weight="1"
49+
android:layout_marginTop="10dp"/>
4550
<ImageButton
4651
android:layout_width="0dp"
4752
android:layout_height="wrap_content"
@@ -56,5 +61,6 @@
5661
android:text="00:00"
5762
android:id="@+id/durationView"
5863
android:maxLines="1"
59-
android:layout_weight="1" />
64+
android:layout_weight="1"
65+
android:layout_marginTop="10dp"/>
6066
</LinearLayout>

0 commit comments

Comments
 (0)