Java Code Examples for tv.danmaku.ijk.media.player.IMediaPlayer#getVideoWidth()

The following examples show how to use tv.danmaku.ijk.media.player.IMediaPlayer#getVideoWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParsingPlayerProxy.java    From ParsingPlayer with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onPrepared(IMediaPlayer mp) {
    LogUtil.i(TAG, "Proxy onPrepared");
    mCurrentState = STATE_PLAYING;
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    int seekToPos = mSeekWhenPrepared;
    if (seekToPos != 0) {
        seekTo(seekToPos);
    }
    if (mVideoHeight != 0 && mVideoWidth != 0) {
        if (mStateListener != null)
            mStateListener.onPrepared(mVideoWidth,
                    mVideoHeight, mVideoSarNum, mVideoSarDen);
    }
}
 
Example 2
Source File: IjkVideoView.java    From AndroidTvDemo with Apache License 2.0 6 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen)
{
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0)
    {
        if (mRenderView != null)
        {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 3
Source File: IjkVideoView.java    From IjkPlayerDemo with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 4
Source File: IjkPlayer.java    From PlayerBase with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    Bundle bundle = BundlePool.obtain();
    bundle.putInt(EventKey.INT_ARG1, mVideoWidth);
    bundle.putInt(EventKey.INT_ARG2, mVideoHeight);
    bundle.putInt(EventKey.INT_ARG3, sarNum);
    bundle.putInt(EventKey.INT_ARG4, sarDen);
    submitPlayerEvent(OnPlayerEventListener.PLAYER_EVENT_ON_VIDEO_SIZE_CHANGE,bundle);
}
 
Example 5
Source File: IjkVideoView.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 6
Source File: IjkVideoView.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 7
Source File: IjkPlayer.java    From DKVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i1, int i2, int i3) {
    int videoWidth = iMediaPlayer.getVideoWidth();
    int videoHeight = iMediaPlayer.getVideoHeight();
    if (videoWidth != 0 && videoHeight != 0) {
        mPlayerEventListener.onVideoSizeChanged(videoWidth, videoHeight);
    }
}
 
Example 8
Source File: JZMediaIjkplayer.java    From JZVideoDemo with MIT License 5 votes vote down vote up
@Override
public void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i1, int i2, int i3) {
    JZMediaManager.instance().currentVideoWidth = iMediaPlayer.getVideoWidth();
    JZMediaManager.instance().currentVideoHeight = iMediaPlayer.getVideoHeight();
    JZMediaManager.instance().mainThreadHandler.post(new Runnable() {
        @Override
        public void run() {
            if (JZVideoPlayerManager.getCurrentJzvd() != null) {
                JZVideoPlayerManager.getCurrentJzvd().onVideoSizeChanged();
            }
        }
    });
}
 
Example 9
Source File: IjkVideoView.java    From TvPlayer with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 10
Source File: MediaPlayerView.java    From HeroVideo-master with Apache License 2.0 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 11
Source File: IjkVideoView.java    From MKVideoPlayer with MIT License 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
        }
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        requestLayout();
    }
}
 
Example 12
Source File: IjkPlayer.java    From VideoDemoJava with MIT License 5 votes vote down vote up
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();
    Bundle bundle = BundlePool.obtain();
    bundle.putInt(EventKey.INT_ARG1, mVideoWidth);
    bundle.putInt(EventKey.INT_ARG2, mVideoHeight);
    bundle.putInt(EventKey.INT_ARG3, sarNum);
    bundle.putInt(EventKey.INT_ARG4, sarDen);
    submitPlayerEvent(OnPlayerEventListener.PLAYER_EVENT_ON_VIDEO_SIZE_CHANGE, bundle);
}
 
Example 13
Source File: ParsingPlayerProxy.java    From ParsingPlayer with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
    mVideoHeight = mp.getVideoHeight();
    mVideoWidth = mp.getVideoWidth();
    mVideoSarNum = mp.getVideoSarNum();
    mVideoSarDen = mp.getVideoSarDen();
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        if (mStateListener != null)
            mStateListener.onVideoSizeChanged(mVideoWidth, mVideoHeight,
                    mVideoSarNum, mVideoSarDen);
    }
}
 
Example 14
Source File: GSYVideoBaseManager.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sar_num, int sar_den) {
    currentVideoWidth = mp.getVideoWidth();
    currentVideoHeight = mp.getVideoHeight();
    mainThreadHandler.post(new Runnable() {
        @Override
        public void run() {
            if (listener() != null) {
                listener().onVideoSizeChanged();
            }
        }
    });
}
 
Example 15
Source File: IjkVideoView.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void onPrepared(IMediaPlayer mp) {
    mPrepareEndTime = System.currentTimeMillis();
    mCurrentState = MediaPlayerParams.STATE_PREPARED;
    _notifyMediaStatus();

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

    if (mOnPreparedListener != null) {
        mOnPreparedListener.onPrepared(mMediaPlayer);
    }
    if (mMediaController != null) {
        mMediaController.setEnabled(true);
    }
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();

    int seekToPosition = mSeekWhenPrepared;  // mSeekWhenPrepared may be changed after seekTo() call
    if (seekToPosition != 0) {
        seekTo(seekToPosition);
    }
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight);
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
            if (!mRenderView.shouldWaitForResize() || mSurfaceWidth == mVideoWidth && mSurfaceHeight == 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 (mTargetState == MediaPlayerParams.STATE_PLAYING) {
                    start();
                    if (mMediaController != null) {
                        mMediaController.show();
                    }
                } else if (!isPlaying() &&
                        (seekToPosition != 0 || getCurrentPosition() > 0)) {
                    if (mMediaController != null) {
                        // Show the media controls when we're paused into a video and make 'em stick.
                        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 (mTargetState == MediaPlayerParams.STATE_PLAYING) {
            start();
        }
    }
}
 
Example 16
Source File: IjkVideoView.java    From ZZShow with Apache License 2.0 4 votes vote down vote up
public void onPrepared(IMediaPlayer mp) {
    mCurrentState = STATE_PREPARED;

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

    if (mOnPreparedListener != null) {
        mOnPreparedListener.onPrepared(mMediaPlayer);
    }
    if (mMediaController != null) {
        mMediaController.setEnabled(true);
    }
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();

    int seekToPosition = mSeekWhenPrepared;  // mSeekWhenPrepared may be changed after seekTo() call
    if (seekToPosition != 0) {
        seekTo(seekToPosition);
    }
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight);
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
            if (!mRenderView.shouldWaitForResize() || mSurfaceWidth == mVideoWidth && mSurfaceHeight == 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 (mTargetState == STATE_PLAYING) {
                    start();
                    if (mMediaController != null) {
                        mMediaController.show();
                    }
                } else if (!isPlaying() &&
                        (seekToPosition != 0 || getCurrentPosition() > 0)) {
                    if (mMediaController != null) {
                        // Show the media controls when we're paused into a video and make 'em stick.
                        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 (mTargetState == STATE_PLAYING) {
            start();
        }
    }
}
 
Example 17
Source File: IjkVideoView.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void onPrepared(IMediaPlayer mp) {
    mPrepareEndTime = System.currentTimeMillis();
    if (mHudViewHolder != null) {
        mHudViewHolder.updateLoadCost(mPrepareEndTime - mPrepareStartTime);
    }
    mCurrentState = STATE_PREPARED;

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

    if (mOnPreparedListener != null) {
        mOnPreparedListener.onPrepared(mMediaPlayer);
    }
    if (mMediaController != null) {
        mMediaController.setEnabled(true);
    }
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();

    int seekToPosition = mSeekWhenPrepared;  // mSeekWhenPrepared may be changed after seekTo() call
    if (seekToPosition != 0) {
        seekTo(seekToPosition);
    }
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight);
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
            if (!mRenderView.shouldWaitForResize() || mSurfaceWidth == mVideoWidth && mSurfaceHeight == 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 (mTargetState == STATE_PLAYING) {
                    start();
                    if (mMediaController != null) {
                        mMediaController.show();
                    }
                } else if (!isPlaying() &&
                        (seekToPosition != 0 || getCurrentPosition() > 0)) {
                    if (mMediaController != null) {
                        // Show the media controls when we're paused into a video and make 'em stick.
                        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 (mTargetState == STATE_PLAYING) {
            start();
        }
    }
}
 
Example 18
Source File: IjkVideoView.java    From LivePlayback with Apache License 2.0 4 votes vote down vote up
public void onPrepared(IMediaPlayer mp) {
    mCurrentState = STATE_PREPARED;

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

    if (mOnPreparedListener != null) {
        mOnPreparedListener.onPrepared(mMediaPlayer);
    }
    if (mMediaController != null) {
        mMediaController.setEnabled(true);
    }
    mVideoWidth = mp.getVideoWidth();
    mVideoHeight = mp.getVideoHeight();

    int seekToPosition = mSeekWhenPrepared;  // mSeekWhenPrepared may be changed after seekTo() call
    if (seekToPosition != 0) {
        seekTo(seekToPosition);
    }
    if (mVideoWidth != 0 && mVideoHeight != 0) {
        //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight);
        // REMOVED: getHolder().setFixedSize(mVideoWidth, mVideoHeight);
        if (mRenderView != null) {
            mRenderView.setVideoSize(mVideoWidth, mVideoHeight);
            mRenderView.setVideoSampleAspectRatio(mVideoSarNum, mVideoSarDen);
            if (!mRenderView.shouldWaitForResize() || mSurfaceWidth == mVideoWidth && mSurfaceHeight == 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 (mTargetState == STATE_PLAYING) {
                    start();
                    if (mMediaController != null) {
                        mMediaController.show();
                    }
                } else if (!isPlaying() &&
                        (seekToPosition != 0 || getCurrentPosition() > 0)) {
                    if (mMediaController != null) {
                        // Show the media controls when we're paused into a video and make 'em stick.
                        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 (mTargetState == STATE_PLAYING) {
            start();
        }
    }
}
 
Example 19
Source File: IjkVideoView.java    From DMusic with Apache License 2.0 4 votes vote down vote up
private void setArgs(IMediaPlayer mp) {
    videoWidth = mp.getVideoWidth();
    videoHeight = mp.getVideoHeight();
    videoSarNum = mp.getVideoSarNum();
    videoSarDen = mp.getVideoSarDen();
}
 
Example 20
Source File: InfoUtil.java    From DMusic with Apache License 2.0 4 votes vote down vote up
public static void showMediaInfo(Context context, IMediaPlayer mMediaPlayer) {
    if (mMediaPlayer == null)
        return;

    int mVideoWidth = mMediaPlayer.getVideoWidth();
    int mVideoHeight = mMediaPlayer.getVideoHeight();
    int mVideoSarNum = mMediaPlayer.getVideoSarNum();
    int mVideoSarDen = mMediaPlayer.getVideoSarDen();

    int selectedVideoTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_VIDEO);
    int selectedAudioTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_AUDIO);
    int selectedSubtitleTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT);

    //media_information
    ULog.d("Player" + MediaPlayerCompat.getName(mMediaPlayer));
    ULog.d("Resolution" + buildResolution(mVideoWidth, mVideoHeight, mVideoSarNum, mVideoSarDen));
    ULog.d("Length" + buildTimeMilli(mMediaPlayer.getDuration()));

    ITrackInfo trackInfos[] = mMediaPlayer.getTrackInfo();
    if (trackInfos != null) {
        int index = -1;
        for (ITrackInfo trackInfo : trackInfos) {
            index++;

            int trackType = trackInfo.getTrackType();
            if (index == selectedVideoTrack) {
                ULog.d("Stream #" + index + " mi__selected_video_track");
            } else if (index == selectedAudioTrack) {
                ULog.d("Stream #" + index + " mi__selected_audio_track");
            } else if (index == selectedSubtitleTrack) {
                ULog.d("Stream #" + index + " mi__selected_subtitle_track");
            } else {
                ULog.d("Stream #" + index);
            }
            ULog.d("Type" + buildTrackType(context, trackType));
            String language = TextUtils.isEmpty(trackInfo.getLanguage()) ? "und" : trackInfo.getLanguage();
            ULog.d("Language:" + language);

            IMediaFormat mediaFormat = trackInfo.getFormat();
            if (mediaFormat == null) {
            } else if (mediaFormat instanceof IjkMediaFormat) {
                switch (trackType) {
                    case ITrackInfo.MEDIA_TRACK_TYPE_VIDEO:
                        ULog.d("Codec:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
                        ULog.d("Profile level:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
                        ULog.d("Pixel format:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PIXEL_FORMAT_UI));
                        ULog.d("Resolution:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_RESOLUTION_UI));
                        ULog.d("Frame rate:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_FRAME_RATE_UI));
                        ULog.d("Bit rate:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
                        break;
                    case ITrackInfo.MEDIA_TRACK_TYPE_AUDIO:
                        ULog.d("Codec:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
                        ULog.d("Profile level:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
                        ULog.d("Sample rate:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_SAMPLE_RATE_UI));
                        ULog.d("Channels:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_CHANNEL_UI));
                        ULog.d("Bit rate:" + mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
                        break;
                    default:
                        break;
                }
            }
        }
    }
}