{"action":"closed","issue":{"url":"https://api.github.com/repos/ksvc/KSYLive_Android/issues/63","repository_url":"https://api.github.com/repos/ksvc/KSYLive_Android","labels_url":"https://api.github.com/repos/ksvc/KSYLive_Android/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/ksvc/KSYLive_Android/issues/63/comments","events_url":"https://api.github.com/repos/ksvc/KSYLive_Android/issues/63/events","html_url":"https://github.com/ksvc/KSYLive_Android/issues/63","id":249931578,"number":63,"title":"TextureView seekTo 成功後 getCurrentPosition() 錯誤","user":{"login":"bingdow","id":2859025,"avatar_url":"https://avatars1.githubusercontent.com/u/2859025?v=4","gravatar_id":"","url":"https://api.github.com/users/bingdow","html_url":"https://github.com/bingdow","followers_url":"https://api.github.com/users/bingdow/followers","following_url":"https://api.github.com/users/bingdow/following{/other_user}","gists_url":"https://api.github.com/users/bingdow/gists{/gist_id}","starred_url":"https://api.github.com/users/bingdow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bingdow/subscriptions","organizations_url":"https://api.github.com/users/bingdow/orgs","repos_url":"https://api.github.com/users/bingdow/repos","events_url":"https://api.github.com/users/bingdow/events{/privacy}","received_events_url":"https://api.github.com/users/bingdow/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-14T04:39:16Z","updated_at":"2017-08-17T02:31:41Z","closed_at":"2017-08-17T02:31:41Z","body":"在調用 seekTo 並成功繼續播放後 getCurrentPosition() 總是回傳錯誤位置，seekbar 又被拉回起點(但影片播放正常)，導致影片播放進度和 seekbar 不一致，代碼如下：\r\n\r\n```\r\npublic int setVideoProgress(int currentProgress, boolean b) {\r\n    if (mVideoView == null)\r\n        return -1;\r\n\r\n    long time = currentProgress > 0 ? currentProgress : mVideoView.getCurrentPosition();\r\n    long length = mVideoView.getDuration();\r\n    if(b){\r\n        Log.v(TAG, \"setVideoProgress: \"+time + \" (note: onStopTrackingTouch)\");\r\n    } else {\r\n        Log.v(TAG, \"setVideoProgress: \"+time + \" (note: UPDATE_SEEKBAR)\");\r\n    }\r\n\r\n    // Update all view elements\r\n    mPlayerSeekbar.setMax((int) length);\r\n    mPlayerSeekbar.setProgress((int) time);\r\n\r\n    if (time >= 0) {\r\n        String progress = time + \"/\" + length;\r\n        mPlayerPosition.setText(progress);\r\n    }\r\n\r\n    Message msg = new Message();\r\n    msg.what = UPDATE_SEEKBAR;\r\n\r\n    if (mHandler != null)\r\n        mHandler.sendMessageDelayed(msg, 1000);\r\n    return (int) time;\r\n}\r\n\r\nprivate int mVideoProgress = 0;\r\nprivate SeekBar.OnSeekBarChangeListener mSeekBarListener = new SeekBar.OnSeekBarChangeListener() {\r\n    @Override\r\n    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {\r\n        if (fromUser) {\r\n            mVideoProgress = progress;\r\n            mHandler.removeMessages(HIDDEN_SEEKBAR);\r\n            Message msg = new Message();\r\n            msg.what = HIDDEN_SEEKBAR;\r\n            mHandler.sendMessageDelayed(msg, 3000);\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onStartTrackingTouch(SeekBar seekBar) {\r\n    }\r\n\r\n    @Override\r\n    public void onStopTrackingTouch(SeekBar seekBar) {\r\n        mVideoView.seekTo(mVideoProgress);\r\n        setVideoProgress(mVideoProgress, true);\r\n    }\r\n};\r\n\r\nprivate IMediaPlayer.OnPreparedListener mOnPreparedListener = new IMediaPlayer.OnPreparedListener() {\r\n    @Override\r\n    public void onPrepared(IMediaPlayer mp) {\r\n        if (mVideoView != null) {\r\n            mVideoView.setVideoScalingMode(KSYMediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);\r\n            mVideoView.start();\r\n            setVideoProgress(0, false);\r\n        }\r\n    }\r\n};\r\n\r\nmHandler = new Handler() {\r\n        @Override\r\n        public void handleMessage(Message msg) {\r\n            super.handleMessage(msg);\r\n            switch (msg.what) {\r\n                case UPDATE_SEEKBAR:\r\n                    setVideoProgress(0, false);\r\n                    break;\r\n                case HIDDEN_SEEKBAR:\r\n                    mPlayerControlShow = false;\r\n                    mPlayerControl.setVisibility(View.GONE);\r\n\r\n                    break;\r\n            }\r\n        }\r\n    };\r\n```\r\n\r\n系統日誌：\r\n```\r\n08-11 23:06:19.193 20910-20910: setVideoProgress: 212743 (note: onStopTrackingTouch)\r\n08-11 23:06:19.214 20910-20910: Buffering Start.\r\n08-11 23:06:19.567 20910-20910: Buffering End.\r\n08-11 23:06:19.682 20910-20910: setVideoProgress: 14 (note: UPDATE_SEEKBAR)\r\n```\r\n\r\n版本：2.4.1\r\nAndroid 版本: 5.0"}}
{"actor":{"display_login":"bingdow"}}