// Path: chat-message-adapter/src/main/java/com/quickblox/ui/kit/chatmessage/adapter/media/AudioController.java
// public class AudioController implements MediaController {
//     private SingleMediaManager mediaManager;
//     private EventMediaController eventMediaController;
// 
//     public AudioController(SingleMediaManager mediaManager, EventMediaController eventMediaController) {
//         this.mediaManager = mediaManager;
//         this.eventMediaController = eventMediaController;
//     }
// 
//     @Override
//     public void onPlayClicked(QBPlaybackControlView view, Uri uri) {
//         eventMediaController.onPlayerInViewInit(view);
//         mediaManager.playMedia(view, uri);
//     }
// 
//     @Override
//     public void onPauseClicked() {
//         mediaManager.pauseMedia();
//     }
// 
//     @Override
//     public void onStopAnyPlayback() {
//         mediaManager.stopAnyPlayback();
//     }
// 
//     @Override
//     public void onStartPosition() {
//         mediaManager.onStartPosition();
//     }
// 
// }
// 
// Path: chat-message-adapter/src/main/java/com/quickblox/ui/kit/chatmessage/adapter/media/utils/ExoPlayerEventListenerImpl.java
// public class ExoPlayerEventListenerImpl implements Player.EventListener {
//     @Override
//     public void onTimelineChanged(Timeline timeline, Object manifest) {
// 
//     }
// 
//     @Override
//     public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
// 
//     }
// 
//     @Override
//     public void onLoadingChanged(boolean isLoading) {
// 
//     }
// 
//     @Override
//     public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
// 
//     }
// 
//     @Override
//     public void onRepeatModeChanged(int repeatMode) {
// 
//     }
// 
//     @Override
//     public void onPlayerError(ExoPlaybackException error) {
// 
//     }
// 
//     @Override
//     public void onPositionDiscontinuity() {
// 
//     }
// 
//     @Override
//     public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
// 
//     }
// }


import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.ui.PlaybackControlView;
import com.quickblox.ui.kit.chatmessage.adapter.R;
import com.quickblox.ui.kit.chatmessage.adapter.media.AudioController;
import com.quickblox.ui.kit.chatmessage.adapter.media.utils.ExoPlayerEventListenerImpl;
    }

    public boolean isCurrentViewPlaying() {
        return getPlayer() != null;
    }

    public void updatePlayPauseIconView() {
        if (!isVisible() || iconPlayPauseView == null) {
            return;
        }
        boolean requestPlayPauseFocus;
        requestPlayPauseFocus = getPlayer() != null && getPlayer().getPlayWhenReady();

        if(requestPlayPauseFocus){
            setPauseStateIcon();
        } else {
            setPlayStateIcon();
        }
    }

    private void setPlayStateIcon() {
        iconPlayPauseView.setActivated(false);
        iconPlayPauseView.setImageState(STATE_SET_PLAY, true);
    }

    private void setPauseStateIcon() {
        iconPlayPauseView.setActivated(true);
        iconPlayPauseView.setImageState(STATE_SET_PAUSE, true);
    }

// Path: chat-message-adapter/src/main/java/com/quickblox/ui/kit/chatmessage/adapter/media/AudioController.java
// public class AudioController implements MediaController {
//     private SingleMediaManager mediaManager;
//     private EventMediaController eventMediaController;
// 
//     public AudioController(SingleMediaManager mediaManager, EventMediaController eventMediaController) {
//         this.mediaManager = mediaManager;
//         this.eventMediaController = eventMediaController;
//     }
// 
//     @Override
//     public void onPlayClicked(QBPlaybackControlView view, Uri uri) {
//         eventMediaController.onPlayerInViewInit(view);
//         mediaManager.playMedia(view, uri);
//     }
// 
//     @Override
//     public void onPauseClicked() {
//         mediaManager.pauseMedia();
//     }
// 
//     @Override
//     public void onStopAnyPlayback() {
//         mediaManager.stopAnyPlayback();
//     }
// 
//     @Override
//     public void onStartPosition() {
//         mediaManager.onStartPosition();
//     }
// 
// }
// 
// Path: chat-message-adapter/src/main/java/com/quickblox/ui/kit/chatmessage/adapter/media/utils/ExoPlayerEventListenerImpl.java
// public class ExoPlayerEventListenerImpl implements Player.EventListener {
//     @Override
//     public void onTimelineChanged(Timeline timeline, Object manifest) {
// 
//     }
// 
//     @Override
//     public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
// 
//     }
// 
//     @Override
//     public void onLoadingChanged(boolean isLoading) {
// 
//     }
// 
//     @Override
//     public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
// 
//     }
// 
//     @Override
//     public void onRepeatModeChanged(int repeatMode) {
// 
//     }
// 
//     @Override
//     public void onPlayerError(ExoPlaybackException error) {
// 
//     }
// 
//     @Override
//     public void onPositionDiscontinuity() {
// 
//     }
// 
//     @Override
//     public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
// 
//     }
// }


// Path: chat-message-adapter/src/main/java/com/quickblox/ui/kit/chatmessage/adapter/media/view/QBPlaybackControlView.java
import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.ui.PlaybackControlView;
import com.quickblox.ui.kit.chatmessage.adapter.R;
import com.quickblox.ui.kit.chatmessage.adapter.media.AudioController;
import com.quickblox.ui.kit.chatmessage.adapter.media.utils.ExoPlayerEventListenerImpl;

    }

    public boolean isCurrentViewPlaying() {
        return getPlayer() != null;
    }

    public void updatePlayPauseIconView() {
        if (!isVisible() || iconPlayPauseView == null) {
            return;
        }
        boolean requestPlayPauseFocus;
        requestPlayPauseFocus = getPlayer() != null && getPlayer().getPlayWhenReady();

        if(requestPlayPauseFocus){
            setPauseStateIcon();
        } else {
            setPlayStateIcon();
        }
    }

    private void setPlayStateIcon() {
        iconPlayPauseView.setActivated(false);
        iconPlayPauseView.setImageState(STATE_SET_PLAY, true);
    }

    private void setPauseStateIcon() {
        iconPlayPauseView.setActivated(true);
        iconPlayPauseView.setImageState(STATE_SET_PAUSE, true);
    }

    private final class ComponentListener extends ExoPlayerEventListenerImpl implements View.OnClickListener {