Java Code Examples for org.telegram.messenger.MessageObject#getDuration()
The following examples show how to use
org.telegram.messenger.MessageObject#getDuration() .
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: AudioPlayerAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void updateProgress(MessageObject messageObject) { if (seekBarView != null) { int newTime; if (seekBarView.isDragging()) { newTime = (int) (messageObject.getDuration() * seekBarView.getProgress()); } else { seekBarView.setProgress(messageObject.audioProgress); seekBarView.setBufferedProgress(messageObject.bufferedProgress); newTime = messageObject.audioProgressSec; } if (lastTime != newTime) { lastTime = newTime; timeTextView.setText(AndroidUtilities.formatShortDuration(newTime)); } } }
Example 2
Source File: AudioPlayerAlert.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void updateProgress(MessageObject messageObject) { if (seekBarView != null) { int newTime; if (seekBarView.isDragging()) { newTime = (int) (messageObject.getDuration() * seekBarView.getProgress()); } else { seekBarView.setProgress(messageObject.audioProgress); seekBarView.setBufferedProgress(messageObject.bufferedProgress); newTime = messageObject.audioProgressSec; } if (lastTime != newTime) { lastTime = newTime; timeTextView.setText(AndroidUtilities.formatShortDuration(newTime)); } } }
Example 3
Source File: AudioPlayerAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = false; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { hasNoCover = true; placeholderImageView.invalidate(); placeholderImageView.setImageDrawable(null); } if (durationTextView != null) { int duration = messageObject.getDuration(); durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--"); } } }
Example 4
Source File: AudioPlayerAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = false; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { hasNoCover = true; placeholderImageView.invalidate(); placeholderImageView.setImageDrawable(null); } if (durationTextView != null) { int duration = messageObject.getDuration(); durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--"); } } }
Example 5
Source File: AudioPlayerAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay)); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause)); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); String loadTitle = author + " " + title; AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = 0; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { String artworkUrl = messageObject.getArtworkUrl(false); if (!TextUtils.isEmpty(artworkUrl)) { placeholderImageView.setImage(artworkUrl, null, null); hasNoCover = 2; } else { placeholderImageView.setImageDrawable(null); hasNoCover = 1; } placeholderImageView.invalidate(); } int duration = messageObject.getDuration(); if (durationTextView != null) { durationTextView.setText(duration != 0 ? AndroidUtilities.formatShortDuration(duration) : "-:--"); } if (duration > 60 * 20) { playbackSpeedButton.setVisibility(View.VISIBLE); } else { playbackSpeedButton.setVisibility(View.GONE); } } }
Example 6
Source File: AudioPlayerAlert.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void updateTitle(boolean shutdown) { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) { dismiss(); } else { if (messageObject == null) { return; } if (messageObject.eventId != 0 || messageObject.getId() <= -2000000000) { hasOptions = false; menuItem.setVisibility(View.INVISIBLE); optionsButton.setVisibility(View.INVISIBLE); } else { hasOptions = true; if (!actionBar.isSearchFieldVisible()) { menuItem.setVisibility(View.VISIBLE); } optionsButton.setVisibility(View.VISIBLE); } checkIfMusicDownloaded(messageObject); updateProgress(messageObject); if (MediaController.getInstance().isMessagePaused()) { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_play, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay)); } else { playButton.setImageDrawable(Theme.createSimpleSelectorDrawable(playButton.getContext(), R.drawable.pl_pause, Theme.getColor(Theme.key_player_button), Theme.getColor(Theme.key_player_buttonActive))); playButton.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause)); } String title = messageObject.getMusicTitle(); String author = messageObject.getMusicAuthor(); titleTextView.setText(title); authorTextView.setText(author); actionBar.setTitle(title); actionBar.setSubtitle(author); String loadTitle = author + " " + title; AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { hasNoCover = 0; placeholderImageView.setImageBitmap(audioInfo.getCover()); } else { String artworkUrl = messageObject.getArtworkUrl(false); if (!TextUtils.isEmpty(artworkUrl)) { placeholderImageView.setImage(artworkUrl, null, null); hasNoCover = 2; } else { placeholderImageView.setImageDrawable(null); hasNoCover = 1; } placeholderImageView.invalidate(); } int duration = messageObject.getDuration(); if (durationTextView != null) { durationTextView.setText(duration != 0 ? AndroidUtilities.formatShortDuration(duration) : "-:--"); } if (duration > 60 * 20) { playbackSpeedButton.setVisibility(View.VISIBLE); } else { playbackSpeedButton.setVisibility(View.GONE); } } }