2024年3月14日发(作者:)

37

38 /* the media player */

39 private AbsMediaPlayer mMediaPlayer = null;

40

41 /* GUI evnet handler */

42 private Handler mEventHandler;

43

44 /* player misc */

45 private ProgressBar mProgressBarPreparing;

46

47 /* player controls */

48 private TextView mTextViewTime;

49 private SeekBar mSeekBarProgress;

50 private TextView mTextViewLength;

51 private ImageButton mImageButtonToggleMessage;

52 private ImageButton mImageButtonSwitchAudio;

53 private ImageButton mImageButtonSwitchSubtitle;

54 private ImageButton mImageButtonPrevious;

55 private ImageButton mImageButtonTogglePlay;

56 private ImageButton mImageButtonNext;

57 private ImageButton mImageButtonSwitchAspectRatio;

58

59 private LinearLayout mLinearLayoutControlBar;

60

61 /* player video */

62 private SurfaceView mSurfaceViewVlc;

63 private SurfaceHolder mSurfaceHolderVlc;

64

65 /* misc */

66 private boolean mMediaPlayerLoaded = false;

67 private boolean mMediaPlayerStarted = false;

68

69 /* misc */

70 private int mTime = -1;

71 private int mLength = -1;

72 private boolean mCanSeek = true;

73 private int mAspectRatio = 0;

74

75 private int mAudioTrackIndex = 0;

76 private int mAudioTrackCount = 0;

77 private int mSubtitleTrackIndex = 0;

78 private int mSubtitleTrackCount = 0;

79

80 private String localUri = null;

81 private String remoteUrl = null;

82 private long mediaLength = 0;

83

84 private int readSize;

85 private boolean isReady;

86 private int errorCount;

87

88 protected boolean isError;

89

90 protected int curPosition;

91

92 private String cacheFilePath;

93

94 protected void initializeEvents() {

95 mEventHandler = new Handler() {

96 public void handleMessage(Message msg) {

97 switch () {

98 case MEDIA_PLAYER_BUFFERING_UPDATE: {

99 if (mMediaPlayerLoaded) {

100 mProgressBarPreparing

101 .setVisibility(1 < 100 ? E

102 : );

103 }

104 }

105 break;

106 case MEDIA_PLAYER_COMPLETION: {

107 curPosition = 0;

108 ();

109 }

110 break;

111 case MEDIA_PLAYER_ERROR: {

112 mMediaPlayerLoaded = true;

113 isError = true;

114 errorCount++;

115 ();

116 ibility(E);

117 }

118 break;

119 case MEDIA_PLAYER_INFO: {

120 if (1 == _INFO_NOT_SEEKABLE) {