Skip to content

Commit 223259a

Browse files
author
Chris Bellew
committed
Fixed crash when playing video on chromecast that has no subtitle streams. Fixed display background of stream selection dialog. Removed references to now playing posters and art. Hopefully fixed resume patterns.
1 parent 42f5e87 commit 223259a

File tree

15 files changed

+43
-47
lines changed

15 files changed

+43
-47
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ public JSONObject buildMedia(Connection connection, int offset) {
589589
data.put(PARAMS.SUBTITLE_SRC, getTranscodeUrl(nowPlayingMedia, connection, offset, true));
590590
data.put(PARAMS.AUDIO_STREAMS, VoiceControlForPlexApplication.gsonWrite.toJson(nowPlayingMedia.getStreams(Stream.AUDIO)));
591591
data.put(PARAMS.SUBTITLE_STREAMS, VoiceControlForPlexApplication.gsonWrite.toJson(nowPlayingMedia.getStreams(Stream.SUBTITLE)));
592-
data.put(PARAMS.ACTIVE_SUBTITLE, nowPlayingMedia.getActiveStream(Stream.SUBTITLE).id);
592+
if(nowPlayingMedia.getActiveStream(Stream.SUBTITLE) != null)
593+
data.put(PARAMS.ACTIVE_SUBTITLE, nowPlayingMedia.getActiveStream(Stream.SUBTITLE).id);
593594
}
594595
data.put(PARAMS.ACCESS_TOKEN, nowPlayingMedia.server.accessToken);
595596
data.put(PARAMS.PLAYLIST, getPlaylistJson());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public void onPlayStarted(PlexMedia media, PlayerState state) {
348348
int layout = getLayoutForMedia(media, state);
349349

350350
if(layout != -1) {
351-
playerFragment.init(layout, client, media, plexSubscriptionListener);
351+
playerFragment.init(layout, client, media, false, plexSubscriptionListener);
352352
switchToFragment(playerFragment);
353353
}
354354
sendWearPlaybackChange(state, media);
@@ -952,7 +952,7 @@ private void handleShowNowPlayingIntent(Intent intent) {
952952
int layout = getLayoutForMedia(media, state);
953953
Logger.d("Layout: %d", layout);
954954
if(layout != -1) {
955-
playerFragment.init(layout, client, media, plexSubscriptionListener);
955+
playerFragment.init(layout, client, media, fromWear, plexSubscriptionListener);
956956
if(playerFragment.isVisible())
957957
playerFragment.mediaChanged(media);
958958
else

mobile/src/main/java/com/atomjack/vcfp/fragments/PlayerFragment.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.graphics.Bitmap;
99
import android.graphics.BitmapFactory;
1010
import android.net.Uri;
11+
import android.os.Build;
1112
import android.os.Bundle;
1213
import android.speech.RecognizerIntent;
1314
import android.support.annotation.Nullable;
@@ -32,35 +33,24 @@
3233
import com.atomjack.shared.Logger;
3334
import com.atomjack.shared.PlayerState;
3435
import com.atomjack.shared.Preferences;
35-
import com.atomjack.shared.SendToDataLayerThread;
3636
import com.atomjack.shared.WearConstants;
37-
import com.atomjack.shared.model.Timeline;
3837
import com.atomjack.vcfp.Feedback;
39-
import com.atomjack.vcfp.PlexHeaders;
4038
import com.atomjack.vcfp.R;
41-
import com.atomjack.vcfp.Utils;
4239
import com.atomjack.vcfp.VoiceControlForPlexApplication;
4340
import com.atomjack.vcfp.activities.MainActivity;
44-
import com.atomjack.vcfp.activities.VCFPActivity;
4541
import com.atomjack.vcfp.adapters.StreamAdapter;
4642
import com.atomjack.vcfp.interfaces.ActiveConnectionHandler;
4743
import com.atomjack.vcfp.interfaces.ActivityListener;
48-
import com.atomjack.vcfp.interfaces.BitmapHandler;
4944
import com.atomjack.vcfp.interfaces.InputStreamHandler;
50-
import com.atomjack.vcfp.interfaces.PlayerFragmentListener;
5145
import com.atomjack.vcfp.interfaces.PlexSubscriptionListener;
5246
import com.atomjack.vcfp.model.Connection;
53-
import com.atomjack.vcfp.model.MediaContainer;
5447
import com.atomjack.vcfp.model.PlexClient;
5548
import com.atomjack.vcfp.model.PlexMedia;
56-
import com.atomjack.vcfp.model.PlexServer;
5749
import com.atomjack.vcfp.model.PlexTrack;
5850
import com.atomjack.vcfp.model.PlexVideo;
5951
import com.atomjack.vcfp.model.Stream;
6052
import com.atomjack.vcfp.net.PlexHttpClient;
61-
import com.atomjack.vcfp.net.PlexHttpMediaContainerHandler;
6253
import com.atomjack.vcfp.services.PlexSearchService;
63-
import com.google.android.gms.wearable.DataMap;
6454

6555
import org.apache.commons.io.IOUtils;
6656

@@ -75,7 +65,6 @@
7565

7666
public abstract class PlayerFragment extends Fragment
7767
implements SeekBar.OnSeekBarChangeListener {
78-
protected PlayerFragmentListener playerFragmentListener;
7968
protected PlexMedia nowPlayingMedia;
8069
protected PlexClient client;
8170

@@ -100,6 +89,8 @@ public abstract class PlayerFragment extends Fragment
10089
protected TextView durationDisplay;
10190
protected ImageView nowPlayingPoster;
10291

92+
protected boolean fromWear = false;
93+
10394
protected GestureDetectorCompat mDetector;
10495

10596
protected Dialog mediaOptionsDialog;
@@ -118,6 +109,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
118109
if(savedInstanceState != null) {
119110
Logger.d("[PlayerFragment] onSavedInstanceState is not null");
120111
nowPlayingMedia = savedInstanceState.getParcelable(Intent.EXTRA_MEDIA);
112+
fromWear = savedInstanceState.getBoolean(WearConstants.FROM_WEAR, false);
121113
layout = savedInstanceState.getInt(Intent.EXTRA_LAYOUT);
122114
client = savedInstanceState.getParcelable(Intent.EXTRA_CLIENT);
123115
}
@@ -156,10 +148,11 @@ public PlayerFragment() {
156148
simpleDiskCache = VoiceControlForPlexApplication.getInstance().mSimpleDiskCache;
157149
}
158150

159-
public void init(int layout, PlexClient client, PlexMedia media, PlexSubscriptionListener plexSubscriptionListener) {
151+
public void init(int layout, PlexClient client, PlexMedia media, boolean fromWear, PlexSubscriptionListener plexSubscriptionListener) {
160152
this.layout = layout;
161153
this.client = client;
162154
nowPlayingMedia = media;
155+
this.fromWear = fromWear;
163156
this.plexSubscriptionListener = plexSubscriptionListener;
164157
}
165158

@@ -290,7 +283,8 @@ public void showNowPlaying(boolean setView) {
290283
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
291284
@Override
292285
public void onGlobalLayout() {
293-
nowPlayingPosterContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
286+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
287+
nowPlayingPosterContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
294288
int height = nowPlayingPosterContainer.getMeasuredHeight();
295289
int width = nowPlayingPosterContainer.getMeasuredWidth();
296290
Logger.d("Found dimensions: %d/%d", width, height);
@@ -556,7 +550,7 @@ protected void doMic() {
556550

557551
SecureRandom random = new SecureRandom();
558552
serviceIntent.setData(Uri.parse(new BigInteger(130, random).toString(32)));
559-
PendingIntent resultsPendingIntent = PendingIntent.getService(getActivity(), 0, serviceIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
553+
PendingIntent resultsPendingIntent = PendingIntent.getService(getActivity(), 0, serviceIntent, PendingIntent.FLAG_ONE_SHOT);
560554

561555
android.content.Intent listenerIntent = new android.content.Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
562556
listenerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
@@ -637,7 +631,6 @@ public void onNothingSelected(AdapterView<?> parent) {
637631
}
638632

639633
builder.setView(layout);
640-
builder.setTitle(getResources().getString(R.string.stream_selection));
641634
mediaOptionsDialog = builder.create();
642635
mediaOptionsDialog.show();
643636
}

mobile/src/main/java/com/atomjack/vcfp/interfaces/PlayerFragmentListener.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

mobile/src/main/java/com/atomjack/vcfp/model/PlexMedia.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public Stream getActiveStream(int streamType) {
214214
return stream;
215215
}
216216

217-
return streams.get(0);
217+
return null;
218218
}
219219

220220
public void setActiveStream(Stream s) {

mobile/src/main/res/layout-land/now_playing_music.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
android:id="@+id/nowPlayingPoster"
8585
android:layout_weight="1"
8686
android:layout_gravity="right"
87-
android:src="@drawable/bonobo2"/>
87+
/>
8888
</FrameLayout>
8989

9090
</LinearLayout>

mobile/src/main/res/layout/media_options_dialog.xml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:orientation="vertical"
44
android:layout_width="match_parent"
5-
android:layout_height="match_parent">
5+
android:layout_height="match_parent"
6+
android:background="@color/settings_popup_background">
7+
8+
<TextView
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:textAppearance="?android:attr/textAppearanceLarge"
12+
android:text="@string/stream_selection"
13+
android:id="@+id/textView12"
14+
android:textColor="@color/white"
15+
android:layout_marginLeft="20dp"
16+
android:layout_marginTop="20dp"
17+
android:layout_marginBottom="20dp"/>
618

719
<LinearLayout
820
android:orientation="horizontal"
@@ -20,7 +32,8 @@
2032
android:layout_width="fill_parent"
2133
android:layout_height="wrap_content"
2234
android:id="@+id/subtitlesSpinner"
23-
android:layout_gravity="center_vertical"/>
35+
android:layout_gravity="center_vertical"
36+
android:popupBackground="@color/settings_popup_background"/>
2437

2538
</LinearLayout>
2639

@@ -40,7 +53,9 @@
4053
android:layout_width="fill_parent"
4154
android:layout_height="wrap_content"
4255
android:id="@+id/audioSpinner"
43-
android:layout_gravity="center_vertical"/>
56+
android:layout_gravity="center_vertical"
57+
android:popupBackground="@color/settings_popup_background"/>
4458

4559
</LinearLayout>
60+
4661
</LinearLayout>

mobile/src/main/res/layout/now_playing_movie.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
android:layout_height="wrap_content"
7272
android:id="@+id/nowPlayingPoster"
7373
android:adjustViewBounds="true"
74-
android:src="@drawable/inception"
7574
android:scaleType="fitXY"
7675
android:layout_gravity="center_horizontal"/>
7776
</FrameLayout>

mobile/src/main/res/layout/now_playing_music.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
android:layout_height="fill_parent"
7676
android:id="@+id/nowPlayingPoster"
7777
android:adjustViewBounds="true"
78-
android:src="@drawable/bonobothumb2"
7978
android:layout_gravity="center_horizontal"
8079
android:scaleType="fitCenter"/>
8180
</FrameLayout>

mobile/src/main/res/layout/now_playing_show.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
android:layout_height="wrap_content"
8484
android:id="@+id/nowPlayingPoster"
8585
android:adjustViewBounds="true"
86-
android:src="@drawable/inception"
8786
android:scaleType="fitXY"
8887
android:layout_gravity="center_horizontal"/>
8988
</FrameLayout>

0 commit comments

Comments
 (0)