[英]Fast load video rewarded Admob and Android Studio?
if you can help me solve, I have a project where I have videos rewarded by admob.如果你能帮我解决,我有一个项目,我有admob奖励的视频。 Everything goes well but I have a small inconvenience.
一切顺利,但我有一个小小的不便。 The videos load when I start the app, but it takes me 20 seconds to load it.
视频在我启动应用程序时加载,但加载它需要 20 秒。 That's a long time and I want it to load in a few seconds.
这是一个很长的时间,我希望它在几秒钟内加载。 How can I make it take less?
我怎样才能让它花费更少? When I finish loading the video I see it.
当我完成加载视频时,我看到了它。 When finished viewing another video is loaded but this one if it loads super fast, in 1 second it is already loaded.
观看完毕后,另一个视频已加载,但如果加载速度超快,则在 1 秒内已加载。 How can I make it load as fast as I can when I start the app?
如何在启动应用程序时尽可能快地加载它? Another problem I have is that some of my users do not upload the videos, they get Rewarded Video Ad Failed To Load, because it could happen?
我遇到的另一个问题是我的一些用户没有上传视频,他们收到奖励视频广告加载失败,因为这可能发生? Only happens to some.
只发生在一些人身上。
package com.android.proyect;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import static android.graphics.BitmapFactory.decodeResource;
import static android.view.Window.FEATURE_LEFT_ICON;
public class Welcome extends AppCompatActivity{
private RewardedVideoAd mRewardedVideoAd;
private static final String AD_UNIT_ID = "ca-app-pub-000000000000000/00000000"; //My code
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Get the view from singleitemview.xml
setContentView(R.layout.activity_welcome);
probarboton = (Button) findViewById(R.id.button4);
//Anuncio probar video
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener()
{
@Override
public void onRewardedVideoAdLoaded()
{
Toast.makeText(Welcome.this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdOpened()
{
Toast.makeText(Welcome.this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoStarted()
{
Toast.makeText(Welcome.this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed()
{
Toast.makeText(Welcome.this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
// Preload the next video ad.
loadRewardedVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem)
{
textView4.setText(String.format(Locale.getDefault(),"you got %d %s!", rewardItem.getAmount(), rewardItem.getType()));
}
@Override
public void onRewardedVideoAdLeftApplication()
{
Toast.makeText(Welcome.this, "onRewardedVideoAdLeftApplication", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdFailedToLoad(int i)
{
Toast.makeText(Welcome.this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}
});
probarboton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
Log.i("probar","video");
System.out.println("click boton probar video");
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
});
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
AdRequest adRewardRequest = new AdRequest.Builder()
.build();
mRewardedVideoAd.loadAd(AD_UNIT_ID, adRewardRequest );
}
}
build.gradle proyect build.gradle 项目
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
build.gradle app build.gradle 应用程序
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.koushikdutta.ion:ion:2.1.9'
compile 'com.android.support:support-vector-drawable:24.2.1'
compile 'com.github.snowdream.android:smartimageview:0.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile files('libs/UnityAdsAdapter.jar')
}
apply plugin: 'com.google.gms.google-services'
您可以在 onRewardedVideoAdClosed() 和 onRewarded() 中调用 loadRewardedVideoAd() 函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.