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.
|
||||
*/
|
||||
/* package */ final class CastDemoUtil {
|
||||
/* package */ final class DemoUtil {
|
||||
|
||||
public static final String MIME_TYPE_DASH = "application/dash+xml";
|
||||
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.
|
||||
|
||||
private final class SampleListAdapter extends ArrayAdapter<CastDemoUtil.Sample> {
|
||||
private final class SampleListAdapter extends ArrayAdapter<DemoUtil.Sample> {
|
||||
|
||||
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
|
||||
@ -112,7 +112,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (parent.getSelectedItemPosition() != position) {
|
||||
CastDemoUtil.Sample currentSample = CastDemoUtil.SAMPLES.get(position);
|
||||
DemoUtil.Sample currentSample = DemoUtil.SAMPLES.get(position);
|
||||
playerManager.setCurrentSample(currentSample, 0, true);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ import com.google.android.gms.cast.framework.CastContext;
|
||||
private final CastPlayer castPlayer;
|
||||
|
||||
private int playbackLocation;
|
||||
private CastDemoUtil.Sample currentSample;
|
||||
private DemoUtil.Sample currentSample;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @param currentSample The {@link CastDemoUtil} to play.
|
||||
* @param currentSample The {@link DemoUtil} to play.
|
||||
* @param positionMs The position at which playback should start.
|
||||
* @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) {
|
||||
this.currentSample = currentSample;
|
||||
if (playbackLocation == PLAYBACK_REMOTE) {
|
||||
@ -144,7 +144,7 @@ import com.google.android.gms.cast.framework.CastContext;
|
||||
|
||||
// Internal methods.
|
||||
|
||||
private static MediaQueueItem buildMediaQueueItem(CastDemoUtil.Sample sample) {
|
||||
private static MediaQueueItem buildMediaQueueItem(DemoUtil.Sample sample) {
|
||||
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
|
||||
movieMetadata.putString(MediaMetadata.KEY_TITLE, sample.name);
|
||||
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();
|
||||
}
|
||||
|
||||
private static MediaSource buildMediaSource(CastDemoUtil.Sample sample) {
|
||||
private static MediaSource buildMediaSource(DemoUtil.Sample sample) {
|
||||
Uri uri = Uri.parse(sample.uri);
|
||||
switch (sample.mimeType) {
|
||||
case CastDemoUtil.MIME_TYPE_SS:
|
||||
case DemoUtil.MIME_TYPE_SS:
|
||||
return new SsMediaSource(uri, DATA_SOURCE_FACTORY,
|
||||
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,
|
||||
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);
|
||||
case CastDemoUtil.MIME_TYPE_VIDEO_MP4:
|
||||
case DemoUtil.MIME_TYPE_VIDEO_MP4:
|
||||
return new ExtractorMediaSource(uri, DATA_SOURCE_FACTORY, new DefaultExtractorsFactory(),
|
||||
null, null);
|
||||
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
|
||||
* {@link DemoPlayer}, which this class instantiates.
|
||||
* {@link PlayerManager}, which this class instantiates.
|
||||
*/
|
||||
public final class MainActivity extends Activity {
|
||||
|
||||
private SimpleExoPlayerView playerView;
|
||||
private DemoPlayer player;
|
||||
private PlayerManager player;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main_activity);
|
||||
playerView = findViewById(R.id.player_view);
|
||||
player = new DemoPlayer(this);
|
||||
player = new PlayerManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,14 +40,14 @@ import com.google.android.exoplayer2.util.Util;
|
||||
/**
|
||||
* Manages the {@link ExoPlayer}, the IMA plugin and all video playback.
|
||||
*/
|
||||
/* package */ final class DemoPlayer {
|
||||
/* package */ final class PlayerManager {
|
||||
|
||||
private final ImaAdsLoader adsLoader;
|
||||
|
||||
private SimpleExoPlayer player;
|
||||
private long contentPosition;
|
||||
|
||||
public DemoPlayer(Context context) {
|
||||
public PlayerManager(Context context) {
|
||||
String adTag = context.getString(R.string.ad_tag_url);
|
||||
adsLoader = new ImaAdsLoader(context, Uri.parse(adTag));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user