خرید بک لینک

Vote count: 0

My class:

             public class MainActivity_For_Youtube extend YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

private static final int RECOVERY_DIALOG_REQUEST = 1;
private YouTubePlayerView playerView;
String fbid="";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Called to modify the window feature and resize to full screen
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.youtubevideo);

     fbid = getIntent().getStringExtra("urls");

    playerView = (YouTubePlayerView) findViewById(R.id.player_view);

    // initializes the YouTube player view
    playerView.initialize(Config.API_KEY, this);
}


// Called when YouTube Player initialization is failed
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
                                    YouTubeInitializationResult errorResult) {

    // shows dialog if user interaction may fix the error
    if (errorResult.isUserRecoverableError()) {
        errorResult.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
    }
    else {
        // displays the error occured during the initialization
        String error = String.format(
                getString(R.string.error_string), errorResult.toString());
        Toast.makeText(this, error, Toast.LENGTH_LONG).show();
    }
}


/**
 * Called when initialization of Player is successful
 * @param provider Provider used to initialize the Player
 * @param player Player instance used to control the video playback
 * @param wasRestored Depicts whether the video is restored from a previous
 *                    state. Retus true if video is resumed from the last
 *                    paused state, else retus false
 */
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
                                    YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {

        player.cueVideo("_oEA18Y8gM0");
        player.setPlayerStyle(PlayerStyle.DEFAULT);
    }
}



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RECOVERY_DIALOG_REQUEST) {

        // initializes the YouTube player view
        getYouTubePlayerProvider().initialize(Config.API_KEY, this);
    }
}


// Retus Player view defined in xml file
private YouTubePlayer.Provider getYouTubePlayerProvider() {
    retu (YouTubePlayerView) findViewById(R.id.player_view);
}


/**
 * 
 */
private final class EventListener implements YouTubePlayer.PlaybackEventListener {


    /**
     * Called when video starts playing
     */
    @Override
    public void onPlaying() {
        Log.e("Status", "Playing");
    }


    /**
     * Called when video stops playing
     */
    @Override
    public void onPaused() {
        Log.e("Status", "Paused");
    }


    /**
     * Called when video stopped for a reason other than paused
     */
    @Override
    public void onStopped() {
        Log.e("Status", "Stopped");
    }


    /**
     * Called when buffering of video starts or ends
     * @param b True if buffering is on, else false
     */
    @Override
    public void onBuffering(boolean b) {
    }


    /**
     * Called when jump in video happens. Reason can be either user scrubbing
     * or seek method is called explicitely
     * @param i
     */
    @Override
    public void onSeekTo(int i) {
    }
}

private final class StateChangeListener implements YouTubePlayer.PlayerStateChangeListener {

    /**
     * Called when player begins loading a video. During this duration, player
     * won't accept any command that may affect the video playback
     */
    @Override
    public void onLoading() {
    }

    /**
     * Called when video is loaded. After this player can accept
     * the playback affecting commands
     * @param s Video Id String
     */
    @Override
    public void onLoaded(String s) {
    }


    /**
     * Called when YouTube ad is started
     */
    @Override
    public void onAdStarted() {
    }


    /**
     * Called when video starts playing
     */
    @Override
    public void onVideoStarted() {
    }


    /**
     * Called when video is ended
     */
    @Override
    public void onVideoEnded() {
    }


    /**
     * Called when any kind of error occurs
     * @param errorReason Error string showing the reason behind it
     */
    @Override
    public void onError(YouTubePlayer.ErrorReason errorReason) {
    }
}

}

*I have got the android key.One thing I have done is updated to android studio 2.0. * I have registered on https://console.developers.google.com/apis/library?project=alien-vim-***** and also enabled youtube data API.Generated the sha-1 and got the android keys.

Getting these errors:

            Error creating YouTubePlayerView  
          com.google.android.youtube.player.inteal.w$a: Exception thrown by invoked
      constructor in com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer 

            Caused by: java.lang.reflect.InvocationTargetException
             Caused by: java.lang.IllegalArgumentException: The concrete class implementing IObjectWrapper must have exactly *one* declared private field for the wrapped object.  Preferably, this is an instance of the ObjectWrapper<T> class.
            Caused by: java.lang.IllegalArgumentException: The concrete class implementing IObjectWrapper must have exactly *one* declared private field for the wrapped object.  Preferably, this is an instance of the ObjectWrapper<T> class. 

asked 44 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 6 ارديبهشت 1395 ساعت: 11:29

صفحه بندی