mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Roll forward of CL 201223315 with ExoPlayer IMA extension fix
Original change by nickchavez@nickchavez:andcsvol:3257:citc on 2018/06/19 12:41:18. Add VolumeProvider interface to VideoAdPlayer and VideoStreamPlayer. - Send volume on videoDisplay.start so that it can be sent to OMID. - Add unit tests for AdPlayerCalback and ExoPlayerVideoAdPlayerImpl. - Add functional tests for client side and DAI volume updates. Add onVolumeChanged() to VideoAdPlayerCallback and VideoStreamPlayerCallback. - Implement volume updates for SDK owned video player. - Remove mute/unmute events, which are handled in JS instead (like iOS). - Collect volume changes from client side and DAI video players. External: Publisher players will now have to implement getVolume() and onVolumeChanged() for custom video players. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202324636
This commit is contained in:
parent
fc2168eb61
commit
6b9fb456a1
@ -53,6 +53,7 @@ import com.google.android.exoplayer2.source.ads.AdPlaybackState;
|
|||||||
import com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState;
|
import com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsLoader;
|
import com.google.android.exoplayer2.source.ads.AdsLoader;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException;
|
import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
@ -269,6 +270,7 @@ public final class ImaAdsLoader
|
|||||||
private ViewGroup adUiViewGroup;
|
private ViewGroup adUiViewGroup;
|
||||||
private VideoProgressUpdate lastContentProgress;
|
private VideoProgressUpdate lastContentProgress;
|
||||||
private VideoProgressUpdate lastAdProgress;
|
private VideoProgressUpdate lastAdProgress;
|
||||||
|
private int lastVolumePercentage;
|
||||||
|
|
||||||
private AdsManager adsManager;
|
private AdsManager adsManager;
|
||||||
private AdLoadException pendingAdLoadError;
|
private AdLoadException pendingAdLoadError;
|
||||||
@ -473,6 +475,7 @@ public final class ImaAdsLoader
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
this.adUiViewGroup = adUiViewGroup;
|
this.adUiViewGroup = adUiViewGroup;
|
||||||
|
lastVolumePercentage = 0;
|
||||||
lastAdProgress = null;
|
lastAdProgress = null;
|
||||||
lastContentProgress = null;
|
lastContentProgress = null;
|
||||||
adDisplayContainer.setAdContainer(adUiViewGroup);
|
adDisplayContainer.setAdContainer(adUiViewGroup);
|
||||||
@ -501,6 +504,7 @@ public final class ImaAdsLoader
|
|||||||
playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
|
playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
|
||||||
adsManager.pause();
|
adsManager.pause();
|
||||||
}
|
}
|
||||||
|
lastVolumePercentage = getVolume();
|
||||||
lastAdProgress = getAdProgress();
|
lastAdProgress = getAdProgress();
|
||||||
lastContentProgress = getContentProgress();
|
lastContentProgress = getContentProgress();
|
||||||
player.removeListener(this);
|
player.removeListener(this);
|
||||||
@ -663,6 +667,27 @@ public final class ImaAdsLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVolume() {
|
||||||
|
if (player == null) {
|
||||||
|
return lastVolumePercentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player.AudioComponent audioComponent = player.getAudioComponent();
|
||||||
|
if (audioComponent != null) {
|
||||||
|
return (int) (audioComponent.getVolume() * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for a selected track using an audio renderer.
|
||||||
|
TrackSelectionArray trackSelections = player.getCurrentTrackSelections();
|
||||||
|
for (int i = 0; i < player.getRendererCount() && i < trackSelections.length; i++) {
|
||||||
|
if (player.getRendererType(i) == C.TRACK_TYPE_AUDIO && trackSelections.get(i) != null) {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAd(String adUriString) {
|
public void loadAd(String adUriString) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user