1. Download our Official Android App: Forums for Android!

not able to play youtube video from webview in moto xoom. but playing in samsung galaxy tab

Discussion in 'Android Apps & Games' started by rafiqsab, Sep 27, 2011.

  1. rafiqsab

    rafiqsab Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Jul 13, 2011

    Jul 13, 2011
    8
    0
    5
    i am using this bellow code.


    private class myWebChromeClient extends WebChromeClient implements OnCompletionListener, OnErrorListener, OnPreparedListener {
    public void complete() {

    onCompletion(mMp);

    }

    @Override
    public void onShowCustomView(View view, CustomViewCallback callback) {

    mCallback = callback;
    youTubeFlag = false;
    super.onShowCustomView(view, callback);

    if (view instanceof FrameLayout) {
    framelayout = (FrameLayout) view;

    if (framelayout.getFocusedChild() instanceof VideoView) {
    mVideoView = (VideoView) framelayout.getFocusedChild();

    mWebView.setVisibility(View.GONE);
    ((LinearLayout) findViewById(R.id.linearLayout_WebView))
    .addView(framelayout);
    framelayout.setVisibility(View.VISIBLE);
    mVideoView.setOnCompletionListener(this);
    mVideoView.setOnErrorListener(this);
    mVideoView.setOnPreparedListener(this);

    }
    }
    }

    @Override
    public void onCompletion(MediaPlayer mp) {

    if (mp != null) {
    if(mp.isPlaying())
    mp.stop();


    }
    mCallback.onCustomViewHidden();
    if(mVideoView.isPlaying())
    mVideoView.stopPlayback();
    mVideoView = null;
    youTubeFlag = false;
    // setViewControl();


    framelayout.setVisibility(View.GONE);
    ((LinearLayout) findViewById(R.id.linearLayout_WebView))
    .removeView(framelayout);
    callsuper();
    mWebView.setVisibility(View.VISIBLE);
    youTubeFlag = true;
    mWebView.loadUrl(mURLToLaunch);

    }

    void callsuper() {

    super.onCloseWindow(mWebView);
    }

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {

    Toast.makeText(getBaseContext(), "" + what + " :" + extra,
    Toast.LENGTH_LONG).show();
    youTubeFlag = false;
    return false;
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
    // TODO Auto-generated method stub
    mMp = mp;
    mVideoView.requestFocus();
    mVideoView.start();
    }
    }
    this code is working properly in emulator and samsung galaxy tab (android2.2), playing well and stopping. but not able to see video in motorola xoom tab (android 3.0), playing only audio and even not stopping after stopping.
    please help me in this regards. its very urgent for me. thanks and regards rafiq
     

    Advertisement

Share This Page

Loading...