images = mediaMetadata.getImages();
94 | if (images.size() == 1) {
95 | return images.get(0);
96 | } else {
97 | if (type == ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) {
98 | return images.get(0);
99 | } else {
100 | return images.get(1);
101 | }
102 | }
103 | }
104 | }*/
105 | }
106 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/cast/CastQuery.java:
--------------------------------------------------------------------------------
1 | package com.sambatech.player.cast;
2 |
3 | import org.json.JSONObject;
4 |
5 |
6 | public class CastQuery {
7 |
8 | private boolean html5;
9 | private String scriptURL;
10 | private String castApi;
11 | private String castAppId;
12 | private String logger;
13 | private long initialTime;
14 | private String captionTheme;
15 |
16 |
17 | public CastQuery() {
18 |
19 | }
20 |
21 | public CastQuery(JSONObject json) {
22 |
23 | this.html5 = json.optBoolean("html5");
24 | this.scriptURL = json.optString("scriptURL");
25 | this.castApi = json.optString("castApi");
26 | this.castAppId = json.optString("castAppId");
27 | this.logger = json.optString("logger");
28 | this.initialTime = json.optLong("initialTime");
29 | this.captionTheme = json.optString("captionTheme");
30 | }
31 |
32 | public boolean getHtml5() {
33 | return this.html5;
34 | }
35 |
36 | public void setHtml5(boolean html5) {
37 | this.html5 = html5;
38 | }
39 |
40 | public String getScriptURL() {
41 | return this.scriptURL;
42 | }
43 |
44 | public void setScriptURL(String scriptURL) {
45 | this.scriptURL = scriptURL;
46 | }
47 |
48 | public String getCastApi() {
49 | return this.castApi;
50 | }
51 |
52 | public void setCastApi(String castApi) {
53 | this.castApi = castApi;
54 | }
55 |
56 | public String getCastAppId() {
57 | return this.castAppId;
58 | }
59 |
60 | public void setCastAppId(String castAppId) {
61 | this.castAppId = castAppId;
62 | }
63 |
64 | public String getLogger() {
65 | return this.logger;
66 | }
67 |
68 | public void setLogger(String logger) {
69 | this.logger = logger;
70 | }
71 |
72 | public long getInitialTime() {
73 | return this.initialTime;
74 | }
75 |
76 | public void setInitialTime(long initialTime) {
77 | this.initialTime = initialTime;
78 | }
79 |
80 |
81 | public String getCaptionTheme() {
82 | return captionTheme;
83 | }
84 |
85 | public void setCaptionTheme(String captionTheme) {
86 | this.captionTheme = captionTheme;
87 | }
88 |
89 | @Override
90 | public String toString() {
91 | return "{" +
92 | "\"html5\":" + html5 +
93 | /*",\"scriptURL\":\"" + scriptURL + '\"' +*/
94 | ",\"castApi\":\"" + castApi + '\"' +
95 | ",\"castAppId\":\"" + castAppId + '\"' +
96 | ",\"captionTheme\":\"" + captionTheme + '\"' +
97 | ",\"initialTime\":" + initialTime +
98 | '}';
99 | }
100 |
101 | public CastQuery(boolean html5, /*String scriptURL,*/ String castApi, String castAppId, long initialTime, String captionTheme) {
102 | this.html5 = html5;
103 | //this.scriptURL = scriptURL;
104 | this.castApi = castApi;
105 | this.castAppId = castAppId;
106 | this.initialTime = initialTime;
107 | this.captionTheme = captionTheme;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/cast/CastTimelineTracker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.sambatech.player.cast;
17 |
18 | import com.google.android.gms.cast.MediaInfo;
19 | import com.google.android.gms.cast.MediaQueueItem;
20 | import com.google.android.gms.cast.MediaStatus;
21 | import java.util.HashMap;
22 | import java.util.HashSet;
23 | import java.util.List;
24 |
25 | /**
26 | * Creates {@link CastTimeline}s from cast receiver app media status.
27 | *
28 | * This class keeps track of the duration reported by the current item to fill any missing
29 | * durations in the media queue items [See internal: b/65152553].
30 | */
31 | /* package */ final class CastTimelineTracker {
32 |
33 | private final HashMap contentIdToDurationUsMap;
34 | private final HashSet scratchContentIdSet;
35 |
36 | public CastTimelineTracker() {
37 | contentIdToDurationUsMap = new HashMap<>();
38 | scratchContentIdSet = new HashSet<>();
39 | }
40 |
41 |
42 | public CastTimeline getCastTimeline(List items, String contentId, long durationUs) {
43 | removeUnusedDurationEntries(items);
44 | contentIdToDurationUsMap.put(contentId, durationUs);
45 | return new CastTimeline(items, contentIdToDurationUsMap);
46 | }
47 |
48 | private void removeUnusedDurationEntries(List items) {
49 | scratchContentIdSet.clear();
50 | for (MediaQueueItem item : items) {
51 | scratchContentIdSet.add(item.getMedia().getContentId());
52 | }
53 | contentIdToDurationUsMap.keySet().retainAll(scratchContentIdSet);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/event/SambaApiCallback.java:
--------------------------------------------------------------------------------
1 | package com.sambatech.player.event;
2 |
3 | import com.sambatech.player.model.SambaMedia;
4 | import com.sambatech.player.model.SambaMediaRequest;
5 |
6 | /**
7 | * Listeners representing server responses.
8 | *
9 | * @author Leandro Zanol - 4/12/15
10 | */
11 | public abstract class SambaApiCallback {
12 |
13 | /**
14 | * Fired up after a unique success response from the server.
15 | * @param media SambaMedia
16 | */
17 | public void onMediaResponse(SambaMedia media) {}
18 |
19 | /**
20 | * Fired up after a set of success responses from the server.
21 | * @param mediaList SambaMedia
22 | */
23 | public void onMediaListResponse(SambaMedia[] mediaList) {}
24 |
25 | /**
26 | *
27 | * Fired up after an error response from the server.
28 | * @param e The raised exception
29 | * @param request Original request
30 | */
31 | public void onMediaResponseError(Exception e, SambaMediaRequest request) {}
32 | }
33 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/event/SambaCastListener.java:
--------------------------------------------------------------------------------
1 | package com.sambatech.player.event;
2 |
3 | import com.google.android.gms.cast.framework.CastSession;
4 |
5 | /**
6 | * @author Leandro Zanol on 3/24/17
7 | */
8 |
9 | public interface SambaCastListener {
10 |
11 | /**
12 | * Dispatched when a connection is established with Chromecast.
13 | */
14 | void onConnected(CastSession castSession);
15 |
16 | void onConnected();
17 |
18 | /**
19 | * Dispatched when a connection is close with Chromecast.
20 | */
21 | void onDisconnected();
22 | }
23 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/event/SambaEvent.java:
--------------------------------------------------------------------------------
1 | package com.sambatech.player.event;
2 |
3 | /**
4 | * @author tmiranda - 9/12/15
5 | */
6 | public class SambaEvent {
7 |
8 | private final SambaEventType type;
9 | private final Object data;
10 | private final Object[] dataAll;
11 |
12 | /**
13 | * SambaEvent default constructor
14 | * @param type {@link SambaPlayerListener.EventType}
15 | */
16 | public SambaEvent(SambaEventType type) {
17 | this(type, new Object[]{});
18 | }
19 |
20 | /**
21 | * SambaEvent constructor
22 | * @param type {@link SambaPlayerListener.EventType}
23 | * @param data An data that can be passed in the event
24 | */
25 | public SambaEvent(SambaEventType type, Object ... data) {
26 | this.type = type;
27 | this.data = data.length > 0 ? data[0] : null;
28 | this.dataAll = data;
29 | }
30 |
31 |
32 | /**
33 | * Get the current event type
34 | * @return {@link SambaPlayerListener.EventType}
35 | */
36 | public SambaEventType getType() {
37 | return type;
38 | }
39 |
40 | /**
41 | * Get the current data
42 | * @return Object
43 | */
44 | public Object getData() {
45 | return data;
46 | }
47 |
48 | /**
49 | * Get all the data
50 | * @return array of objects
51 | */
52 | public Object[] getDataAll() {
53 | return dataAll;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/sambaplayersdk/src/main/java/com/sambatech/player/event/SambaEventBus.java:
--------------------------------------------------------------------------------
1 | package com.sambatech.player.event;
2 |
3 | import android.util.Log;
4 |
5 | import java.lang.reflect.Method;
6 | import java.lang.reflect.Modifier;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.ListIterator;
11 |
12 | /**
13 | * @author Leandro Zanol - 10/12/15
14 | */
15 | public class SambaEventBus {
16 |
17 | private static EventBus _eventBus = new EventBus();
18 |
19 | private SambaEventBus() {}
20 |
21 | /**
22 | * Registers an event.
23 | * @param listener listener object
24 | */
25 | public static void subscribe(Object listener) {
26 | _eventBus.subscribe(listener);
27 | }
28 |
29 | /**
30 | * Unregisters an event.
31 | * @param listener listener object
32 | */
33 | public static void unsubscribe(Object listener) {
34 | _eventBus.unsubscribe(listener);
35 | }
36 |
37 | /**
38 | * Triggers an event.
39 | * @param e a particular event
40 | */
41 | public static void post(SambaEvent e) {
42 | _eventBus.post(e);
43 | }
44 |
45 | private static class EventBus {
46 | private HashMap> listeners = new HashMap<>();
47 | private List