// 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 long setProgress() {
        if (isDragging) {
            return 0;
        }
        //check player is active
        boolean currentPlayer = videoView.isCurrentActivePlayer();
        if (!currentPlayer) {
            seekBar.setProgress(0);
            return 0;
        }

        //check player is ready
        GiraffePlayer player = videoView.getPlayer();
        int currentState = player.getCurrentState();
        if (currentState == GiraffePlayer.STATE_IDLE ||
                currentState == GiraffePlayer.STATE_PREPARING ||
                currentState == GiraffePlayer.STATE_ERROR) {
            return 0;
        }

        long position = player.getCurrentPosition();
        int duration = player.getDuration();

        if (seekBar != null) {
            if (duration > 0) {
                long pos = 1000L * position / duration;
                seekBar.setProgress((int) pos);
            }
// 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 long setProgress() {
        if (isDragging) {
            return 0;
        }
        //check player is active
        boolean currentPlayer = videoView.isCurrentActivePlayer();
        if (!currentPlayer) {
            seekBar.setProgress(0);
            return 0;
        }

        //check player is ready
        GiraffePlayer player = videoView.getPlayer();
        int currentState = player.getCurrentState();
        if (currentState == GiraffePlayer.STATE_IDLE ||
                currentState == GiraffePlayer.STATE_PREPARING ||
                currentState == GiraffePlayer.STATE_ERROR) {
            return 0;
        }

        long position = player.getCurrentPosition();
        int duration = player.getDuration();

        if (seekBar != null) {
            if (duration > 0) {
                long pos = 1000L * position / duration;
                seekBar.setProgress((int) pos);
            }
            int percent = player.getBufferPercentage();