{"action":"created","issue":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/906","labels_url":"https://api.github.com/repos/google/ExoPlayer/issues/906/labels{/name}","comments_url":"https://api.github.com/repos/google/ExoPlayer/issues/906/comments","events_url":"https://api.github.com/repos/google/ExoPlayer/issues/906/events","html_url":"https://github.com/google/ExoPlayer/issues/906","id":113852307,"number":906,"title":"getBufferedPercentage for streaming before being able to play","user":{"login":"ripleyXLR8","id":4702185,"avatar_url":"https://avatars.githubusercontent.com/u/4702185?v=3","gravatar_id":"","url":"https://api.github.com/users/ripleyXLR8","html_url":"https://github.com/ripleyXLR8","followers_url":"https://api.github.com/users/ripleyXLR8/followers","following_url":"https://api.github.com/users/ripleyXLR8/following{/other_user}","gists_url":"https://api.github.com/users/ripleyXLR8/gists{/gist_id}","starred_url":"https://api.github.com/users/ripleyXLR8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripleyXLR8/subscriptions","organizations_url":"https://api.github.com/users/ripleyXLR8/orgs","repos_url":"https://api.github.com/users/ripleyXLR8/repos","events_url":"https://api.github.com/users/ripleyXLR8/events{/privacy}","received_events_url":"https://api.github.com/users/ripleyXLR8/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-28T15:46:40Z","updated_at":"2015-10-28T20:01:50Z","closed_at":"2015-10-28T20:01:50Z","body":"Hi everybody,\r\n\r\nI'm using ExoPlayer as an HLS stream player (streams are genereted by Wowza) and I need to be able to display the current percentage buffered before the stream will be able to play.\r\n\r\nIn fact \"getBufferedPercentage\" return me the total amount of the total track which is currently buffered and not the percentage buffered before the player will be able to play the stream.\r\n\r\nIs there a function that can returns this information? Or a way to compute it?\r\n\r\nBest regards\r\nRichard"},"comment":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/comments/151973688","html_url":"https://github.com/google/ExoPlayer/issues/906#issuecomment-151973688","issue_url":"https://api.github.com/repos/google/ExoPlayer/issues/906","id":151973688,"user":{"login":"ojw28","id":7881572,"avatar_url":"https://avatars.githubusercontent.com/u/7881572?v=3","gravatar_id":"","url":"https://api.github.com/users/ojw28","html_url":"https://github.com/ojw28","followers_url":"https://api.github.com/users/ojw28/followers","following_url":"https://api.github.com/users/ojw28/following{/other_user}","gists_url":"https://api.github.com/users/ojw28/gists{/gist_id}","starred_url":"https://api.github.com/users/ojw28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojw28/subscriptions","organizations_url":"https://api.github.com/users/ojw28/orgs","repos_url":"https://api.github.com/users/ojw28/repos","events_url":"https://api.github.com/users/ojw28/events{/privacy}","received_events_url":"https://api.github.com/users/ojw28/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T20:01:50Z","updated_at":"2015-10-28T20:01:50Z","body":"You could do something like this to get an estimate of the duration currently buffered:\r\n\r\n```\r\nint estimatedBufferDuration = ExoPlayer.UNKNOWN_TIME;\r\nint estimatedBufferPosition = player.getBufferedPosition();\r\nif (estimatedBufferPosition != Exoplayer.UNKNOWN_TIME) {\r\n  estimatedBufferDuration = estimatedBufferPosition - getCurrentPosition();\r\n}\r\n```\r\n\r\nYou could then compare this to the duration that needs to be buffered for playback to start, which is the second argument passed to `ExoPlayer.Factory.newInstance` when creating the player, or `ExoPlayer.Factory.DEFAULT_MIN_BUFFER_MS` if you're using the one-arg version of that method. If you're handling a re-buffer, compare to the third argument or `ExoPlayer.Factory.DEFAULT_MIN_REBUFFER_MS`.\r\n\r\nYou'd probably end up with something like:\r\n\r\n```\r\nint percentage = 0;\r\nif (estimatedBufferDuration != ExoPlayer.UNKNOWN_TIME) {\r\n  percentage = (estimatedBufferDuration * 100) / ExoPlayer.Factory.DEFAULT_MIN_BUFFER_MS;\r\n  percentage = Math.max(0, Math.min(100, percentage));\r\n}\r\n```\r\n\r\nWhen you create an ExoPlayer using ExoPlayer.newInstance, the second argument is the minimum duration that needs to be buffered before playback starts and the third argument is the minimum duration that needs to be buffered before playback resumes following a re-buffer.\r\n\r\n- You can use `player.getCurrentPosition() "}}