Ejemplo n.º 1
0
            //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
            //ORIGINAL LINE: public void onSurfaceChanged(@NonNull IRenderView.ISurfaceHolder holder, int format, int w, int h)
            public void onSurfaceChanged(IRenderView_ISurfaceHolder holder, int format, int w, int h)
            {
                if (holder.RenderView != outerInstance.mRenderView)
                {
                    Log.Error(outerInstance.TAG, "onSurfaceChanged: unmatched render callback\n");
                    return;
                }

                outerInstance.mSurfaceWidth  = w;
                outerInstance.mSurfaceHeight = h;
                bool isValidState = (outerInstance.mTargetState == STATE_PLAYING);
                bool hasValidSize = !outerInstance.mRenderView.shouldWaitForResize() || (outerInstance.mVideoWidth == w && outerInstance.mVideoHeight == h);

                if (outerInstance.mMediaPlayer != null && isValidState && hasValidSize)
                {
                    if (outerInstance.mSeekWhenPrepared != 0)
                    {
                        outerInstance.SeekTo((int)outerInstance.mSeekWhenPrepared);
                    }
                    outerInstance.Start();
                }
            }
Ejemplo n.º 2
0
            public void OnPrepared(IMediaPlayer mp)
            {
                outerInstance.mCurrentState = STATE_PREPARED;

                // Get the capabilities of the player for this stream
                // REMOVED: Metadata

                if (outerInstance.mOnPreparedListener != null)
                {
                    outerInstance.mOnPreparedListener.OnPrepared(outerInstance.mMediaPlayer);
                }
                if (outerInstance.mMediaController != null)
                {
                    outerInstance.mMediaController.Enabled = true;
                }
                outerInstance.mVideoWidth  = mp.VideoWidth;
                outerInstance.mVideoHeight = mp.VideoHeight;

                long seekToPosition = outerInstance.mSeekWhenPrepared; // mSeekWhenPrepared may be changed after seekTo() call

                if (seekToPosition != 0)
                {
                    outerInstance.SeekTo((int)seekToPosition);
                }
                if (outerInstance.mVideoWidth != 0 && outerInstance.mVideoHeight != 0)
                {
                    //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight);
                    // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
                    if (outerInstance.mRenderView != null)
                    {
                        outerInstance.mRenderView.setVideoSize(outerInstance.mVideoWidth, outerInstance.mVideoHeight);
                        outerInstance.mRenderView.setVideoSampleAspectRatio(outerInstance.mVideoSarNum, outerInstance.mVideoSarDen);
                        if (!outerInstance.mRenderView.shouldWaitForResize() || outerInstance.mSurfaceWidth == outerInstance.mVideoWidth && outerInstance.mSurfaceHeight == outerInstance.mVideoHeight)
                        {
                            // We didn't actually change the size (it was already at the size
                            // we need), so we won't get a "surface changed" callback, so
                            // start the video here instead of in the callback.
                            if (outerInstance.mTargetState == STATE_PLAYING)
                            {
                                outerInstance.Start();
                                if (outerInstance.mMediaController != null)
                                {
                                    outerInstance.mMediaController.Show();
                                }
                            }
                            else if (!outerInstance.IsPlaying && (seekToPosition != 0 || outerInstance.CurrentPosition > 0))
                            {
                                if (outerInstance.mMediaController != null)
                                {
                                    // Show the media controls when we're paused into a video and make 'em stick.
                                    outerInstance.mMediaController.Show(0);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // We don't know the video size yet, but should start anyway.
                    // The video size might be reported to us later.
                    if (outerInstance.mTargetState == STATE_PLAYING)
                    {
                        outerInstance.Start();
                    }
                }
            }