// Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/trackselector/TrackSelectorFragment.java
// public class TrackSelectorFragment extends DialogFragment{
//     private ViewQuery $;
// 
//     @Nullable
//     @Override
//     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//         getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
//         View view = inflater.inflate(R.layout.giraffe_track_selector, container, false);
//         $ = new ViewQuery(view);
//         return view;
//     }
// 
//     @Override
//     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//         ExpandableListView list = $.id(R.id.app_video_track_list).view();
// 
//         $.id(R.id.app_video_track_close).clicked(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 dismissAllowingStateLoss();
// //                getFragmentManager().beginTransaction().remove(TrackSelectorFragment.this).commit();
//             }
//         });
// 
//         final TracksAdapter tracksAdapter = new TracksAdapter();
//         list.setGroupIndicator(null);
//         list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
//             @Override
//             public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
//                 return true;
//             }
//         });
//         list.setAdapter(tracksAdapter);
//         tracksAdapter.load(getArguments().getString("fingerprint"));
//         int count = tracksAdapter.getGroupCount();
//         for ( int i = 0; i < count; i++ ) {
//             list.expandGroup(i);
//         }
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.github.tcking.giraffeplayer2.R;
import java.util.Locale;
import tcking.github.com.giraffeplayer2.trackselector.TrackSelectorFragment;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkTimedText;
    protected final View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            GiraffePlayer player = videoView.getPlayer();
            if (v.getId() == R.id.app_video_fullscreen) {
                player.toggleFullScreen();
            } else if (v.getId() == R.id.app_video_play) {
                if (player.isPlaying()) {
                    player.pause();
                } else {
                    player.start();
                }
            } else if (v.getId() == R.id.app_video_replay_icon) {
                player.seekTo(0);
                player.start();
//                videoView.seekTo(0);
//                videoView.start();
//                doPauseResume();
            } else if (v.getId() == R.id.app_video_finish) {
                if (!player.onBackPressed()) {
                    ((Activity) videoView.getContext()).finish();
                }
            } else if (v.getId() == R.id.app_video_float_close) {
                player.stop();
                player.setDisplayModel(GiraffePlayer.DISPLAY_NORMAL);
            } else if (v.getId() == R.id.app_video_float_full) {
                player.setDisplayModel(GiraffePlayer.DISPLAY_FULL_WINDOW);
            } else if (v.getId() == R.id.app_video_clarity) {
                Activity activity = (Activity) videoView.getContext();
                if (activity instanceof AppCompatActivity) {
// Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/trackselector/TrackSelectorFragment.java
// public class TrackSelectorFragment extends DialogFragment{
//     private ViewQuery $;
// 
//     @Nullable
//     @Override
//     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//         getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
//         View view = inflater.inflate(R.layout.giraffe_track_selector, container, false);
//         $ = new ViewQuery(view);
//         return view;
//     }
// 
//     @Override
//     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//         ExpandableListView list = $.id(R.id.app_video_track_list).view();
// 
//         $.id(R.id.app_video_track_close).clicked(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 dismissAllowingStateLoss();
// //                getFragmentManager().beginTransaction().remove(TrackSelectorFragment.this).commit();
//             }
//         });
// 
//         final TracksAdapter tracksAdapter = new TracksAdapter();
//         list.setGroupIndicator(null);
//         list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
//             @Override
//             public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
//                 return true;
//             }
//         });
//         list.setAdapter(tracksAdapter);
//         tracksAdapter.load(getArguments().getString("fingerprint"));
//         int count = tracksAdapter.getGroupCount();
//         for ( int i = 0; i < count; i++ ) {
//             list.expandGroup(i);
//         }
//     }
// }


// Path: giraffeplayer2/src/main/java/tcking/github/com/giraffeplayer2/DefaultMediaController.java
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.github.tcking.giraffeplayer2.R;
import java.util.Locale;
import tcking.github.com.giraffeplayer2.trackselector.TrackSelectorFragment;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkTimedText;

    protected final View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            GiraffePlayer player = videoView.getPlayer();
            if (v.getId() == R.id.app_video_fullscreen) {
                player.toggleFullScreen();
            } else if (v.getId() == R.id.app_video_play) {
                if (player.isPlaying()) {
                    player.pause();
                } else {
                    player.start();
                }
            } else if (v.getId() == R.id.app_video_replay_icon) {
                player.seekTo(0);
                player.start();
//                videoView.seekTo(0);
//                videoView.start();
//                doPauseResume();
            } else if (v.getId() == R.id.app_video_finish) {
                if (!player.onBackPressed()) {
                    ((Activity) videoView.getContext()).finish();
                }
            } else if (v.getId() == R.id.app_video_float_close) {
                player.stop();
                player.setDisplayModel(GiraffePlayer.DISPLAY_NORMAL);
            } else if (v.getId() == R.id.app_video_float_full) {
                player.setDisplayModel(GiraffePlayer.DISPLAY_FULL_WINDOW);
            } else if (v.getId() == R.id.app_video_clarity) {
                Activity activity = (Activity) videoView.getContext();
                if (activity instanceof AppCompatActivity) {
                    TrackSelectorFragment trackSelectorFragment = new TrackSelectorFragment();