private InstreamAudioAd ad;
private void initAd()
{
// Enable debug mode
// InstreamAudioAd.setDebugMode(true);
// Create an instance of InstreamAudioAd
ad = new InstreamAudioAd(YOUR_SLOT_ID, this);
}
private InstreamAudioAd ad;
private void initAd()
{
// Create an instance of InstreamAudioAd
ad = new InstreamAudioAd(YOUR_SLOT_ID, this);
// Install the player
ad.setPlayer(YOUR_PLAYER);
}
float getAdAudioDuration();
float getAdAudioPosition();
void setAdPlayerListener(AdPlayerListener listener);
Context getCurrentContext();
void setVolume(float volume);
void playAdAudio(Uri uri);
void pauseAdAudio();
void resumeAdAudio();
void stopAdAudio();
void onAdAudioStarted();
void onAdAudioPaused();
void onAdAudioResumed();
void onAdAudioStopped();
void onAdAudioError(String message);
void onAdAudioCompleted();
void onVolumeChanged(float volume);
private InstreamAudioAd ad;
private void initAd()
{
// Create an instance of InstreamAudioAd
ad = new InstreamAudioAd(YOUR_SLOT_ID, this);
// Install the event listener
ad.setListener(new InstreamAudioAd.InstreamAudioAdListener()
{
@Override
public void onLoad(InstreamAudioAd ad)
{
// Data uploaded successfully
}
@Override
public void onNoAd(String reason, InstreamAudioAd ad)
{
// Data not received
}
@Override
public void onError(String reason, InstreamAudioAd ad)
{
// An error occurred while playing the ad audio
}
@Override
public void onBannerStart(InstreamAudioAd ad, InstreamAudioAd.InstreamAudioAdBanner banner)
{
// Ad Audio Playback Started
}
@Override
public void onBannerComplete(InstreamAudioAd ad, InstreamAudioAd.InstreamAudioAdBanner banner)
{
// Ad Audio Playback Completed
}
@Override
public void onBannerTimeLeftChange(float timeLeft, float duration, InstreamAudioAd ad)
{
// Called repeatedly during the playback of advertising audio, used to update the timer until the end of the display of advertising audio
}
@Override
public void onComplete(String section, InstreamAudioAd ad)
{
// Playback of all advertising audio in the advertising section is completed.
}
});
// We start data loading
ad.load();
}
// Before you start playing the main audio
ad.startPreroll();
// After playing the main audio
ad.startPostroll();
private InstreamAudioAd ad;
private void initAd()
{
// Create an instance of InstreamAudioAd
ad = new InstreamAudioAd(YOUR_SLOT_ID, this);
// Set the position in the first and fifth seconds of audio
ad.configureMidpoints(videoDuration, new float[]{1f,5f});
// or as a percentage, at 10% and 50% audio
// ad.configureMidpointsPercents(audioDuration, new float[]{10f,50f});
// Install the event listener
ad.setListener(new InstreamAudioAd.InstreamAudioAdListener()
{
@Override
public void onLoad(InstreamAudioAd ad)
{
// Data uploaded successfully
// Array of positions (in seconds) available for playing midroll section
adPositions = ad.getMidPoints();
}
...
});
// We start data loading
ad.load();
}
// Audio played out to the 5th second and for it there is a position in the adPositions array
ad.startMidroll(adPositions[1]);
float getDuration();
boolean isAllowSeek();
boolean isAllowSkip();
boolean isAllowTrackChange();
List<InstreamAdCompanionBanner> getInstreamAdCompanionBanners();
String getAdText();
private void onCompanionAdShow(InstreamAdCompanionBanner companionBanner)
{
ad.handleCompanionShow(companionBanner);
}
private void onCompanionAdClick(InstreamAdCompanionBanner companionBanner)
{
// Processing a click in the context of current activity
ad.handleCompanionClick(companionBanner, context);
// Processing a click in the context that was passed during the creation of the advertising instance
// ad.handleCompanionClick(companionBanner);
}
public void pause()
public void resume()
public void stop()
public void skip()
public void skipBanner()
public void setVolume(float volume)
public void setLoadingTimeout(int loadingTimeout)
private InstreamAudioAd ad;
private void initAd()
{
// Create an instance of InstreamAudioAd
ad = new InstreamAudioAd(YOUR_SLOT_ID, this);
// Receive an instance of additional parameters CustomParams
CustomParams customParams = ad.getCustomParams();
// Set age
customParams.setAge(25);
// Set gender
customParams.setGender(CustomParams.Gender.MALE);
}