Align naming across demo apps.
- Dropped class name prefixes that correspond to whole app name - Anything that wraps the player is called PlayerManager ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173652288
This commit is contained in:
parent
30f95cdcac
commit
345084b8fe
@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Utility methods and constants for the Cast demo application.
|
* Utility methods and constants for the Cast demo application.
|
||||||
*/
|
*/
|
||||||
/* package */ final class CastDemoUtil {
|
/* package */ final class DemoUtil {
|
||||||
|
|
||||||
public static final String MIME_TYPE_DASH = "application/dash+xml";
|
public static final String MIME_TYPE_DASH = "application/dash+xml";
|
||||||
public static final String MIME_TYPE_HLS = "application/vnd.apple.mpegurl";
|
public static final String MIME_TYPE_HLS = "application/vnd.apple.mpegurl";
|
||||||
@ -87,6 +87,6 @@ import java.util.List;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CastDemoUtil() {}
|
private DemoUtil() {}
|
||||||
|
|
||||||
}
|
}
|
@ -91,10 +91,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// User controls.
|
// User controls.
|
||||||
|
|
||||||
private final class SampleListAdapter extends ArrayAdapter<CastDemoUtil.Sample> {
|
private final class SampleListAdapter extends ArrayAdapter<DemoUtil.Sample> {
|
||||||
|
|
||||||
public SampleListAdapter() {
|
public SampleListAdapter() {
|
||||||
super(getApplicationContext(), android.R.layout.simple_list_item_1, CastDemoUtil.SAMPLES);
|
super(getApplicationContext(), android.R.layout.simple_list_item_1, DemoUtil.SAMPLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +112,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if (parent.getSelectedItemPosition() != position) {
|
if (parent.getSelectedItemPosition() != position) {
|
||||||
CastDemoUtil.Sample currentSample = CastDemoUtil.SAMPLES.get(position);
|
DemoUtil.Sample currentSample = DemoUtil.SAMPLES.get(position);
|
||||||
playerManager.setCurrentSample(currentSample, 0, true);
|
playerManager.setCurrentSample(currentSample, 0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ import com.google.android.gms.cast.framework.CastContext;
|
|||||||
private final CastPlayer castPlayer;
|
private final CastPlayer castPlayer;
|
||||||
|
|
||||||
private int playbackLocation;
|
private int playbackLocation;
|
||||||
private CastDemoUtil.Sample currentSample;
|
private DemoUtil.Sample currentSample;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param exoPlayerView The {@link SimpleExoPlayerView} for local playback.
|
* @param exoPlayerView The {@link SimpleExoPlayerView} for local playback.
|
||||||
@ -88,11 +88,11 @@ import com.google.android.gms.cast.framework.CastContext;
|
|||||||
/**
|
/**
|
||||||
* Starts playback of the given sample at the given position.
|
* Starts playback of the given sample at the given position.
|
||||||
*
|
*
|
||||||
* @param currentSample The {@link CastDemoUtil} to play.
|
* @param currentSample The {@link DemoUtil} to play.
|
||||||
* @param positionMs The position at which playback should start.
|
* @param positionMs The position at which playback should start.
|
||||||
* @param playWhenReady Whether the player should proceed when ready to do so.
|
* @param playWhenReady Whether the player should proceed when ready to do so.
|
||||||
*/
|
*/
|
||||||
public void setCurrentSample(CastDemoUtil.Sample currentSample, long positionMs,
|
public void setCurrentSample(DemoUtil.Sample currentSample, long positionMs,
|
||||||
boolean playWhenReady) {
|
boolean playWhenReady) {
|
||||||
this.currentSample = currentSample;
|
this.currentSample = currentSample;
|
||||||
if (playbackLocation == PLAYBACK_REMOTE) {
|
if (playbackLocation == PLAYBACK_REMOTE) {
|
||||||
@ -144,7 +144,7 @@ import com.google.android.gms.cast.framework.CastContext;
|
|||||||
|
|
||||||
// Internal methods.
|
// Internal methods.
|
||||||
|
|
||||||
private static MediaQueueItem buildMediaQueueItem(CastDemoUtil.Sample sample) {
|
private static MediaQueueItem buildMediaQueueItem(DemoUtil.Sample sample) {
|
||||||
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
|
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
|
||||||
movieMetadata.putString(MediaMetadata.KEY_TITLE, sample.name);
|
movieMetadata.putString(MediaMetadata.KEY_TITLE, sample.name);
|
||||||
MediaInfo mediaInfo = new MediaInfo.Builder(sample.uri)
|
MediaInfo mediaInfo = new MediaInfo.Builder(sample.uri)
|
||||||
@ -153,18 +153,18 @@ import com.google.android.gms.cast.framework.CastContext;
|
|||||||
return new MediaQueueItem.Builder(mediaInfo).build();
|
return new MediaQueueItem.Builder(mediaInfo).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MediaSource buildMediaSource(CastDemoUtil.Sample sample) {
|
private static MediaSource buildMediaSource(DemoUtil.Sample sample) {
|
||||||
Uri uri = Uri.parse(sample.uri);
|
Uri uri = Uri.parse(sample.uri);
|
||||||
switch (sample.mimeType) {
|
switch (sample.mimeType) {
|
||||||
case CastDemoUtil.MIME_TYPE_SS:
|
case DemoUtil.MIME_TYPE_SS:
|
||||||
return new SsMediaSource(uri, DATA_SOURCE_FACTORY,
|
return new SsMediaSource(uri, DATA_SOURCE_FACTORY,
|
||||||
new DefaultSsChunkSource.Factory(DATA_SOURCE_FACTORY), null, null);
|
new DefaultSsChunkSource.Factory(DATA_SOURCE_FACTORY), null, null);
|
||||||
case CastDemoUtil.MIME_TYPE_DASH:
|
case DemoUtil.MIME_TYPE_DASH:
|
||||||
return new DashMediaSource(uri, DATA_SOURCE_FACTORY,
|
return new DashMediaSource(uri, DATA_SOURCE_FACTORY,
|
||||||
new DefaultDashChunkSource.Factory(DATA_SOURCE_FACTORY), null, null);
|
new DefaultDashChunkSource.Factory(DATA_SOURCE_FACTORY), null, null);
|
||||||
case CastDemoUtil.MIME_TYPE_HLS:
|
case DemoUtil.MIME_TYPE_HLS:
|
||||||
return new HlsMediaSource(uri, DATA_SOURCE_FACTORY, null, null);
|
return new HlsMediaSource(uri, DATA_SOURCE_FACTORY, null, null);
|
||||||
case CastDemoUtil.MIME_TYPE_VIDEO_MP4:
|
case DemoUtil.MIME_TYPE_VIDEO_MP4:
|
||||||
return new ExtractorMediaSource(uri, DATA_SOURCE_FACTORY, new DefaultExtractorsFactory(),
|
return new ExtractorMediaSource(uri, DATA_SOURCE_FACTORY, new DefaultExtractorsFactory(),
|
||||||
null, null);
|
null, null);
|
||||||
default: {
|
default: {
|
||||||
|
@ -22,19 +22,19 @@ import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Activity for the IMA plugin demo. {@link ExoPlayer} objects are created by
|
* Main Activity for the IMA plugin demo. {@link ExoPlayer} objects are created by
|
||||||
* {@link DemoPlayer}, which this class instantiates.
|
* {@link PlayerManager}, which this class instantiates.
|
||||||
*/
|
*/
|
||||||
public final class MainActivity extends Activity {
|
public final class MainActivity extends Activity {
|
||||||
|
|
||||||
private SimpleExoPlayerView playerView;
|
private SimpleExoPlayerView playerView;
|
||||||
private DemoPlayer player;
|
private PlayerManager player;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main_activity);
|
setContentView(R.layout.main_activity);
|
||||||
playerView = findViewById(R.id.player_view);
|
playerView = findViewById(R.id.player_view);
|
||||||
player = new DemoPlayer(this);
|
player = new PlayerManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,14 +40,14 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
/**
|
/**
|
||||||
* Manages the {@link ExoPlayer}, the IMA plugin and all video playback.
|
* Manages the {@link ExoPlayer}, the IMA plugin and all video playback.
|
||||||
*/
|
*/
|
||||||
/* package */ final class DemoPlayer {
|
/* package */ final class PlayerManager {
|
||||||
|
|
||||||
private final ImaAdsLoader adsLoader;
|
private final ImaAdsLoader adsLoader;
|
||||||
|
|
||||||
private SimpleExoPlayer player;
|
private SimpleExoPlayer player;
|
||||||
private long contentPosition;
|
private long contentPosition;
|
||||||
|
|
||||||
public DemoPlayer(Context context) {
|
public PlayerManager(Context context) {
|
||||||
String adTag = context.getString(R.string.ad_tag_url);
|
String adTag = context.getString(R.string.ad_tag_url);
|
||||||
adsLoader = new ImaAdsLoader(context, Uri.parse(adTag));
|
adsLoader = new ImaAdsLoader(context, Uri.parse(adTag));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user