YouTube api arka planda çalışma özelliğini nasıl verebilirim
09.10.2019 - 06:35
package views.sub4sub.com.sub4subviewspro;
import android.content.Intent;
import android.media.audiofx.DynamicsProcessing;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
import androidx.appcompat.app.AppCompatActivity;
public class youtubeapiActivity extends AppCompatActivity implements YouTubePlayer.OnInitializedListener {
private static final int RECOVERY_REQUEST = 1;
private YouTubePlayerView youTubeView;
Button seekToButton;
int a, b, c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtubeapi);
youTubeView = (YouTubePlayerView) findViewById(R.id.youTubeView);
youTubeView.initialize(DynamicsProcessing.Config.YOUTUBE_API_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.cueVideo("fhWaJi1Hsfo"); // Plays https://www.youtube.com/watch?v=fhWaJi1Hsfo
player.play();
});
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_REQUEST).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RECOVERY_REQUEST)
getYouTubePlayerProvider().initialize(new DynamicsProcessing.Config.YOUTUBE_API_KEY, this);
}
protected YouTubePlayer.Provider getYouTubePlayerProvider() {
return youTubeView;
}
}
Merhaba bana youtube api konusunda arka planda çalışma özelliğini verebilecek var mı 5 aydır yapmaya çalışıyorum lütfen bilen varsa söylesin
18
Görüntülenme
0 Beğeni