- * When done with the IjkMediaPlayer, you should call {@link #release()}, to
- * free the resources. If not released, too many IjkMediaPlayer instances
- * may result in an exception.
- *
- */
- public IjkMediaPlayer() {
- this(sLocalLibLoader);
- }
-
- /**
- * do not loadLibaray
- * @param libLoader
- * custom library loader, can be null.
- */
- public IjkMediaPlayer(IjkLibLoader libLoader) {
- initPlayer(libLoader);
- }
-
- private void initPlayer(IjkLibLoader libLoader) {
- loadLibrariesOnce(libLoader);
- initNativeOnce();
-
- Looper looper;
- if ((looper = Looper.myLooper()) != null) {
- mEventHandler = new EventHandler(this, looper);
- } else if ((looper = Looper.getMainLooper()) != null) {
- mEventHandler = new EventHandler(this, looper);
- } else {
- mEventHandler = null;
- }
-
- /*
- * Native setup requires a weak reference to our object. It's easier to
- * create it here than in C++.
- */
- native_setup(new WeakReference(this));
- }
-
- /*
- * Update the IjkMediaPlayer SurfaceTexture. Call after setting a new
- * display surface.
- */
- private native void _setVideoSurface(Surface surface);
-
- /**
- * Sets the {@link SurfaceHolder} to use for displaying the video portion of
- * the media.
- *
- * Either a surface holder or surface must be set if a display or video sink
- * is needed. Not calling this method or {@link #setSurface(Surface)} when
- * playing back a video will result in only the audio track being played. A
- * null surface holder or surface will result in only the audio track being
- * played.
- *
- * @param sh
- * the SurfaceHolder to use for video display
- */
- @Override
- public void setDisplay(SurfaceHolder sh) {
- mSurfaceHolder = sh;
- Surface surface;
- if (sh != null) {
- surface = sh.getSurface();
- } else {
- surface = null;
- }
- _setVideoSurface(surface);
- updateSurfaceScreenOn();
- }
-
- /**
- * Sets the {@link Surface} to be used as the sink for the video portion of
- * the media. This is similar to {@link #setDisplay(SurfaceHolder)}, but
- * does not support {@link #setScreenOnWhilePlaying(boolean)}. Setting a
- * Surface will un-set any Surface or SurfaceHolder that was previously set.
- * A null surface will result in only the audio track being played.
- *
- * If the Surface sends frames to a {@link SurfaceTexture}, the timestamps
- * returned from {@link SurfaceTexture#getTimestamp()} will have an
- * unspecified zero point. These timestamps cannot be directly compared
- * between different media sources, different instances of the same media
- * source, or multiple runs of the same program. The timestamp is normally
- * monotonically increasing and is unaffected by time-of-day adjustments,
- * but it is reset when the position is set.
- *
- * @param surface
- * The {@link Surface} to be used for the video portion of the
- * media.
- */
- @Override
- public void setSurface(Surface surface) {
- if (mScreenOnWhilePlaying && surface != null) {
- DebugLog.w(TAG,
- "setScreenOnWhilePlaying(true) is ineffective for Surface");
- }
- mSurfaceHolder = null;
- _setVideoSurface(surface);
- updateSurfaceScreenOn();
- }
-
- /**
- * Sets the data source (file-path or http/rtsp URL) to use.
- *
- * @param path
- * the path of the file, or the http/rtsp URL of the stream you
- * want to play
- * @throws IllegalStateException
- * if it is called in an invalid state
- *
- *
- * When path
refers to a local file, the file may
- * actually be opened by a process other than the calling
- * application. This implies that the pathname should be an
- * absolute path (as any other process runs with unspecified
- * current working directory), and that the pathname should
- * reference a world-readable file.
- */
- @Override
- public void setDataSource(String path) throws IOException,
- IllegalArgumentException, SecurityException, IllegalStateException {
- mDataSource = path;
- _setDataSource(path, null, null);
- }
-
- private native void _setDataSource(String path, String[] keys,
- String[] values) throws IOException, IllegalArgumentException,
- SecurityException, IllegalStateException;
-
- @Override
- public String getDataSource() {
- return mDataSource;
- }
-
- public void setDataSourceAsFFConcatContent(String ffConcatContent) {
- mFFConcatContent = ffConcatContent;
- }
-
- @Override
- public void prepareAsync() throws IllegalStateException {
- if (TextUtils.isEmpty(mFFConcatContent)) {
- _prepareAsync();
- } else {
- _prepareAsync();
- }
- }
-
- public native void _prepareAsync() throws IllegalStateException;
-
- @Override
- public void start() throws IllegalStateException {
- stayAwake(true);
- _start();
- }
-
- private native void _start() throws IllegalStateException;
-
- @Override
- public void stop() throws IllegalStateException {
- stayAwake(false);
- _stop();
- }
-
- private native void _stop() throws IllegalStateException;
-
- @Override
- public void pause() throws IllegalStateException {
- stayAwake(false);
- _pause();
- }
-
- private native void _pause() throws IllegalStateException;
-
- @SuppressLint("Wakelock")
- @Override
- public void setWakeMode(Context context, int mode) {
- boolean washeld = false;
- if (mWakeLock != null) {
- if (mWakeLock.isHeld()) {
- washeld = true;
- mWakeLock.release();
- }
- mWakeLock = null;
- }
-
- PowerManager pm = (PowerManager) context
- .getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(mode | PowerManager.ON_AFTER_RELEASE,
- IjkMediaPlayer.class.getName());
- mWakeLock.setReferenceCounted(false);
- if (washeld) {
- mWakeLock.acquire();
- }
- }
-
- @Override
- public void setScreenOnWhilePlaying(boolean screenOn) {
- if (mScreenOnWhilePlaying != screenOn) {
- if (screenOn && mSurfaceHolder == null) {
- DebugLog.w(TAG,
- "setScreenOnWhilePlaying(true) is ineffective without a SurfaceHolder");
- }
- mScreenOnWhilePlaying = screenOn;
- updateSurfaceScreenOn();
- }
- }
-
- @SuppressLint("Wakelock")
- private void stayAwake(boolean awake) {
- if (mWakeLock != null) {
- if (awake && !mWakeLock.isHeld()) {
- mWakeLock.acquire();
- } else if (!awake && mWakeLock.isHeld()) {
- mWakeLock.release();
- }
- }
- mStayAwake = awake;
- updateSurfaceScreenOn();
- }
-
- private void updateSurfaceScreenOn() {
- if (mSurfaceHolder != null) {
- mSurfaceHolder.setKeepScreenOn(mScreenOnWhilePlaying && mStayAwake);
- }
- }
-
- @Override
- public int getVideoWidth() {
- return mVideoWidth;
- }
-
- @Override
- public int getVideoHeight() {
- return mVideoHeight;
- }
-
- @Override
- public int getVideoSarNum() {
- return mVideoSarNum;
- }
-
- @Override
- public int getVideoSarDen() {
- return mVideoSarDen;
- }
-
- @Override
- public native boolean isPlaying();
-
- @Override
- public native void seekTo(long msec) throws IllegalStateException;
-
- @Override
- public native long getCurrentPosition();
-
- @Override
- public native long getDuration();
-
- /**
- * Releases resources associated with this IjkMediaPlayer object. It is
- * considered good practice to call this method when you're done using the
- * IjkMediaPlayer. In particular, whenever an Activity of an application is
- * paused (its onPause() method is called), or stopped (its onStop() method
- * is called), this method should be invoked to release the IjkMediaPlayer
- * object, unless the application has a special need to keep the object
- * around. In addition to unnecessary resources (such as memory and
- * instances of codecs) being held, failure to call this method immediately
- * if a IjkMediaPlayer object is no longer needed may also lead to
- * continuous battery consumption for mobile devices, and playback failure
- * for other applications if no multiple instances of the same codec are
- * supported on a device. Even if multiple instances of the same codec are
- * supported, some performance degradation may be expected when unnecessary
- * multiple instances are used at the same time.
- */
- @Override
- public void release() {
- stayAwake(false);
- updateSurfaceScreenOn();
- resetListeners();
- _release();
- }
-
- private native void _release();
-
- @Override
- public void reset() {
- stayAwake(false);
- _reset();
- // make sure none of the listeners get called anymore
- mEventHandler.removeCallbacksAndMessages(null);
-
- mVideoWidth = 0;
- mVideoHeight = 0;
- }
-
- private native void _reset();
-
- public native void setVolume(float leftVolume, float rightVolume);
-
- @Override
- public MediaInfo getMediaInfo() {
- MediaInfo mediaInfo = new MediaInfo();
- mediaInfo.mMediaPlayerName = "ijkplayer";
-
- String videoCodecInfo = _getVideoCodecInfo();
- if (!TextUtils.isEmpty(videoCodecInfo)) {
- String nodes[] = videoCodecInfo.split(",");
- if (nodes.length >= 2) {
- mediaInfo.mVideoDecoder = nodes[0];
- mediaInfo.mVideoDecoderImpl = nodes[1];
- } else if (nodes.length >= 1) {
- mediaInfo.mVideoDecoder = nodes[0];
- mediaInfo.mVideoDecoderImpl = "";
- }
- }
-
- String audioCodecInfo = _getAudioCodecInfo();
- if (!TextUtils.isEmpty(audioCodecInfo)) {
- String nodes[] = audioCodecInfo.split(",");
- if (nodes.length >= 2) {
- mediaInfo.mAudioDecoder = nodes[0];
- mediaInfo.mAudioDecoderImpl = nodes[1];
- } else if (nodes.length >= 1) {
- mediaInfo.mAudioDecoder = nodes[0];
- mediaInfo.mAudioDecoderImpl = "";
- }
- }
-
- try {
- mediaInfo.mMeta = IjkMediaMeta.parse(_getMediaMeta());
- } catch (Throwable e) {
- e.printStackTrace();
- }
- return mediaInfo;
- }
-
- private native String _getVideoCodecInfo();
- private native String _getAudioCodecInfo();
-
- public void setOption(int category, String name, String value)
- {
- _setOption(category, name, value);
- }
-
- public void setOption(int category, String name, long value)
- {
- _setOption(category, name, value);
- }
-
- @Deprecated
- public void setAvOption(AvFormatOption option) {
- setAvFormatOption(option.getName(), option.getValue());
- }
-
- @Deprecated
- public void setAvFormatOption(String name, String value) {
- setOption(OPT_CATEGORY_FORMAT, name, value);
- }
-
- @Deprecated
- public void setAvCodecOption(String name, String value) {
- setOption(OPT_CATEGORY_CODEC, name, value);
- }
-
- @Deprecated
- public void setSwScaleOption(String name, String value) {
- setOption(OPT_CATEGORY_SWS, name, value);
- }
-
- @Deprecated
- public void setOverlayFormat(int chromaFourCC) {
- setOption(OPT_CATEGORY_PLAYER, "overlay-format", chromaFourCC);
- }
-
- @Deprecated
- public void setFrameDrop(int frameDrop) {
- setOption(OPT_CATEGORY_PLAYER, "framedrop", frameDrop);
- }
-
- @Deprecated
- public void setMediaCodecEnabled(boolean enabled) {
- setOption(OPT_CATEGORY_PLAYER, "mediacodec", enabled ? 1 : 0);
- }
-
- @Deprecated
- public void setOpenSLESEnabled(boolean enabled) {
- setOption(OPT_CATEGORY_PLAYER, "opengles", enabled ? 1 : 0);
- }
-
- @Deprecated
- public void setAutoPlayOnPrepared(boolean enabled) {
- setOption(OPT_CATEGORY_PLAYER, "start-on-prepared", enabled ? 1 : 0);
- }
-
- private native void _setOption(int category, String name, String value);
- private native void _setOption(int category, String name, long value);
-
- public Bundle getMediaMeta() {
- return _getMediaMeta();
- }
- private native Bundle _getMediaMeta();
-
- public static String getColorFormatName(int mediaCodecColorFormat) {
- return _getColorFormatName(mediaCodecColorFormat);
- }
-
- private static native String _getColorFormatName(int mediaCodecColorFormat);
-
- @Override
- public void setAudioStreamType(int streamtype) {
- // do nothing
- }
-
- private static native void native_init();
-
- private native void native_setup(Object IjkMediaPlayer_this);
-
- private native void native_finalize();
-
- private native void native_message_loop(Object IjkMediaPlayer_this);
-
- protected void finalize() {
- native_finalize();
- }
-
- private static class EventHandler extends Handler {
- private WeakReference mWeakPlayer;
-
- public EventHandler(IjkMediaPlayer mp, Looper looper) {
- super(looper);
- mWeakPlayer = new WeakReference(mp);
- }
-
- @Override
- public void handleMessage(Message msg) {
- IjkMediaPlayer player = mWeakPlayer.get();
- if (player == null || player.mNativeMediaPlayer == 0) {
- DebugLog.w(TAG,
- "IjkMediaPlayer went away with unhandled events");
- return;
- }
-
- switch (msg.what) {
- case MEDIA_PREPARED:
- player.notifyOnPrepared();
- return;
-
- case MEDIA_PLAYBACK_COMPLETE:
- player.notifyOnCompletion();
- player.stayAwake(false);
- return;
-
- case MEDIA_BUFFERING_UPDATE:
- long bufferPosition = msg.arg1;
- if (bufferPosition < 0) {
- bufferPosition = 0;
- }
-
- long percent = 0;
- long duration = player.getDuration();
- if (duration > 0) {
- percent = bufferPosition * 100 / duration;
- }
- if (percent >= 100) {
- percent = 100;
- }
-
- // DebugLog.efmt(TAG, "Buffer (%d%%) %d/%d", percent, bufferPosition, duration);
- player.notifyOnBufferingUpdate((int)percent);
- return;
-
- case MEDIA_SEEK_COMPLETE:
- player.notifyOnSeekComplete();
- return;
-
- case MEDIA_SET_VIDEO_SIZE:
- player.mVideoWidth = msg.arg1;
- player.mVideoHeight = msg.arg2;
- player.notifyOnVideoSizeChanged(player.mVideoWidth, player.mVideoHeight,
- player.mVideoSarNum, player.mVideoSarDen);
- return;
-
- case MEDIA_ERROR:
- DebugLog.e(TAG, "Error (" + msg.arg1 + "," + msg.arg2 + ")");
- if (!player.notifyOnError(msg.arg1, msg.arg2)) {
- player.notifyOnCompletion();
- }
- player.stayAwake(false);
- return;
-
- case MEDIA_INFO:
- if (msg.arg1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) {
- DebugLog.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")");
- }
- player.notifyOnInfo(msg.arg1, msg.arg2);
- // No real default action so far.
- return;
- case MEDIA_TIMED_TEXT:
- // do nothing
- break;
-
- case MEDIA_NOP: // interface test message - ignore
- break;
-
- case MEDIA_SET_VIDEO_SAR:
- player.mVideoSarNum = msg.arg1;
- player.mVideoSarDen = msg.arg2;
- player.notifyOnVideoSizeChanged(player.mVideoWidth, player.mVideoHeight,
- player.mVideoSarNum, player.mVideoSarDen);
- break;
-
- default:
- DebugLog.e(TAG, "Unknown message type " + msg.what);
- return;
- }
- }
- }
-
- /*
- * Called from native code when an interesting event happens. This method
- * just uses the EventHandler system to post the event back to the main app
- * thread. We use a weak reference to the original IjkMediaPlayer object so
- * that the native code is safe from the object disappearing from underneath
- * it. (This is the cookie passed to native_setup().)
- */
- @CalledByNative
- private static void postEventFromNative(Object weakThiz, int what,
- int arg1, int arg2, Object obj) {
- if (weakThiz == null)
- return;
-
- @SuppressWarnings("rawtypes")
- IjkMediaPlayer mp = (IjkMediaPlayer) ((WeakReference) weakThiz).get();
- if (mp == null) {
- return;
- }
-
- if (what == MEDIA_INFO && arg1 == MEDIA_INFO_STARTED_AS_NEXT) {
- // this acquires the wakelock if needed, and sets the client side
- // state
- mp.start();
- }
- if (mp.mEventHandler != null) {
- Message m = mp.mEventHandler.obtainMessage(what, arg1, arg2, obj);
- mp.mEventHandler.sendMessage(m);
- }
- }
-
- private OnControlMessageListener mOnControlMessageListener;
- public void setOnControlMessageListener(OnControlMessageListener listener) {
- mOnControlMessageListener = listener;
- }
-
- public static interface OnControlMessageListener {
- public int onControlResolveSegmentCount();
- public String onControlResolveSegmentUrl(int segment);
- public String onControlResolveSegmentOfflineMrl(int segment);
- public int onControlResolveSegmentDuration(int segment);
- }
-
- @CalledByNative
- private static int onControlResolveSegmentCount(Object weakThiz) {
- DebugLog.ifmt(TAG, "onControlResolveSegmentCount");
- if (weakThiz == null || !(weakThiz instanceof WeakReference>))
- return -1;
-
- @SuppressWarnings("unchecked")
- WeakReference weakPlayer = (WeakReference) weakThiz;
- IjkMediaPlayer player = weakPlayer.get();
- if (player == null)
- return -1;
-
- OnControlMessageListener listener = player.mOnControlMessageListener;
- if (listener == null)
- return -1;
-
- return listener.onControlResolveSegmentCount();
- }
-
- @CalledByNative
- private static String onControlResolveSegmentUrl(Object weakThiz, int segment) {
- DebugLog.ifmt(TAG, "onControlResolveSegmentUrl %d", segment);
- if (weakThiz == null || !(weakThiz instanceof WeakReference>))
- return null;
-
- @SuppressWarnings("unchecked")
- WeakReference weakPlayer = (WeakReference) weakThiz;
- IjkMediaPlayer player = weakPlayer.get();
- if (player == null)
- return null;
-
- OnControlMessageListener listener = player.mOnControlMessageListener;
- if (listener == null)
- return null;
-
- return listener.onControlResolveSegmentUrl(segment);
- }
-
- @CalledByNative
- private static String onControlResolveSegmentOfflineMrl(Object weakThiz, int segment) {
- DebugLog.ifmt(TAG, "onControlResolveSegmentOfflineMrl %d", segment);
- if (weakThiz == null || !(weakThiz instanceof WeakReference>))
- return null;
-
- @SuppressWarnings("unchecked")
- WeakReference weakPlayer = (WeakReference) weakThiz;
- IjkMediaPlayer player = weakPlayer.get();
- if (player == null)
- return null;
-
- OnControlMessageListener listener = player.mOnControlMessageListener;
- if (listener == null)
- return null;
-
- return listener.onControlResolveSegmentOfflineMrl(segment);
- }
-
- @CalledByNative
- private static int onControlResolveSegmentDuration(Object weakThiz, int segment) {
- DebugLog.ifmt(TAG, "onControlResolveSegmentDuration %d", segment);
- if (weakThiz == null || !(weakThiz instanceof WeakReference>))
- return -1;
-
- @SuppressWarnings("unchecked")
- WeakReference weakPlayer = (WeakReference) weakThiz;
- IjkMediaPlayer player = weakPlayer.get();
- if (player == null)
- return -1;
-
- OnControlMessageListener listener = player.mOnControlMessageListener;
- if (listener == null)
- return -1;
-
- return listener.onControlResolveSegmentDuration(segment);
- }
-
- public static interface OnMediaCodecSelectListener {
- public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level);
- }
- private OnMediaCodecSelectListener mOnMediaCodecSelectListener;
- public void setOnMediaCodecSelectListener(OnMediaCodecSelectListener listener) {
- mOnMediaCodecSelectListener = listener;
- }
-
- public void resetListeners() {
- super.resetListeners();
- mOnMediaCodecSelectListener = null;
- }
-
- @CalledByNative
- private static String onSelectCodec(Object weakThiz, String mimeType, int profile, int level) {
- if (weakThiz == null || !(weakThiz instanceof WeakReference>))
- return null;
-
- @SuppressWarnings("unchecked")
- WeakReference weakPlayer = (WeakReference) weakThiz;
- IjkMediaPlayer player = weakPlayer.get();
- if (player == null)
- return null;
-
- OnMediaCodecSelectListener listener = player.mOnMediaCodecSelectListener;
- if (listener == null)
- listener = DefaultMediaCodecSelector.sInstance;
-
- return listener.onMediaCodecSelect(player, mimeType, profile, level);
- }
-
- public static class DefaultMediaCodecSelector implements OnMediaCodecSelectListener {
- public static DefaultMediaCodecSelector sInstance = new DefaultMediaCodecSelector();
-
- @SuppressWarnings("deprecation")
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- public String onMediaCodecSelect(IMediaPlayer mp, String mimeType, int profile, int level) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
- return null;
-
- if (TextUtils.isEmpty(mimeType))
- return null;
-
- Log.i(TAG, String.format(Locale.US, "onSelectCodec: mime=%s, profile=%d, level=%d", mimeType, profile, level));
- ArrayList candidateCodecList = new ArrayList();
- int numCodecs = MediaCodecList.getCodecCount();
- for (int i = 0; i < numCodecs; i++) {
- MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
- Log.d(TAG, String.format(Locale.US, " found codec: %s", codecInfo.getName()));
- if (codecInfo.isEncoder())
- continue;
-
- String[] types = codecInfo.getSupportedTypes();
- if (types == null)
- continue;
-
- for(String type: types) {
- if (TextUtils.isEmpty(type))
- continue;
-
- Log.d(TAG, String.format(Locale.US, " mime: %s", type));
- if (!type.equalsIgnoreCase(mimeType))
- continue;
-
- IjkMediaCodecInfo candidate = IjkMediaCodecInfo.setupCandidate(codecInfo, mimeType);
- if (candidate == null)
- continue;
-
- candidateCodecList.add(candidate);
- Log.i(TAG, String.format(Locale.US, "candidate codec: %s rank=%d", codecInfo.getName(), candidate.mRank));
- candidate.dumpProfileLevels(mimeType);
- }
- }
-
- if (candidateCodecList.isEmpty()) {
- return null;
- }
-
- IjkMediaCodecInfo bestCodec = candidateCodecList.get(0);
-
- for (IjkMediaCodecInfo codec : candidateCodecList) {
- if (codec.mRank > bestCodec.mRank) {
- bestCodec = codec;
- }
- }
-
- if (bestCodec.mRank < IjkMediaCodecInfo.RANK_LAST_CHANCE) {
- Log.w(TAG, String.format(Locale.US, "unaccetable codec: %s", bestCodec.mCodecInfo.getName()));
- return null;
- }
-
- Log.i(TAG, String.format(Locale.US, "selected codec: %s rank=%d", bestCodec.mCodecInfo.getName(), bestCodec.mRank));
- return bestCodec.mCodecInfo.getName();
- }
- }
-
- public static native void native_profileBegin(String libName);
- public static native void native_profileEnd();
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/SimpleMediaPlayer.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/SimpleMediaPlayer.java
deleted file mode 100755
index 6c3f626..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/SimpleMediaPlayer.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player;
-
-/**
- * @author bbcallen
- *
- * Common IMediaPlayer implement
- */
-public abstract class SimpleMediaPlayer extends BaseMediaPlayer implements
- IMediaPlayer {
- private OnPreparedListener mOnPreparedListener;
- private OnCompletionListener mOnCompletionListener;
- private OnBufferingUpdateListener mOnBufferingUpdateListener;
- private OnSeekCompleteListener mOnSeekCompleteListener;
- private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
- private OnErrorListener mOnErrorListener;
- private OnInfoListener mOnInfoListener;
-
- public final void setOnPreparedListener(OnPreparedListener listener) {
- mOnPreparedListener = listener;
- }
-
- public final void setOnCompletionListener(OnCompletionListener listener) {
- mOnCompletionListener = listener;
- }
-
- public final void setOnBufferingUpdateListener(
- OnBufferingUpdateListener listener) {
- mOnBufferingUpdateListener = listener;
- }
-
- public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
- mOnSeekCompleteListener = listener;
- }
-
- public final void setOnVideoSizeChangedListener(
- OnVideoSizeChangedListener listener) {
- mOnVideoSizeChangedListener = listener;
- }
-
- public final void setOnErrorListener(OnErrorListener listener) {
- mOnErrorListener = listener;
- }
-
- public final void setOnInfoListener(OnInfoListener listener) {
- mOnInfoListener = listener;
- }
-
- public void resetListeners() {
- mOnPreparedListener = null;
- mOnBufferingUpdateListener = null;
- mOnCompletionListener = null;
- mOnSeekCompleteListener = null;
- mOnVideoSizeChangedListener = null;
- mOnErrorListener = null;
- mOnInfoListener = null;
- }
-
- public void attachListeners(IMediaPlayer mp) {
- mp.setOnPreparedListener(mOnPreparedListener);
- mp.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
- mp.setOnCompletionListener(mOnCompletionListener);
- mp.setOnSeekCompleteListener(mOnSeekCompleteListener);
- mp.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
- mp.setOnErrorListener(mOnErrorListener);
- mp.setOnInfoListener(mOnInfoListener);
- }
-
- protected final void notifyOnPrepared() {
- if (mOnPreparedListener != null)
- mOnPreparedListener.onPrepared(this);
- }
-
- protected final void notifyOnCompletion() {
- if (mOnCompletionListener != null)
- mOnCompletionListener.onCompletion(this);
- }
-
- protected final void notifyOnBufferingUpdate(int percent) {
- if (mOnBufferingUpdateListener != null)
- mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
- }
-
- protected final void notifyOnSeekComplete() {
- if (mOnSeekCompleteListener != null)
- mOnSeekCompleteListener.onSeekComplete(this);
- }
-
- protected final void notifyOnVideoSizeChanged(int width, int height,
- int sarNum, int sarDen) {
- if (mOnVideoSizeChangedListener != null)
- mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
- sarNum, sarDen);
- }
-
- protected final boolean notifyOnError(int what, int extra) {
- if (mOnErrorListener != null)
- return mOnErrorListener.onError(this, what, extra);
- return false;
- }
-
- protected final boolean notifyOnInfo(int what, int extra) {
- if (mOnInfoListener != null)
- return mOnInfoListener.onInfo(this, what, extra);
- return false;
- }
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java
deleted file mode 100755
index 60db0d2..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @CalledByNative is used by the JNI generator to create the necessary JNI
- * bindings and expose this method to native code.
- */
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.CLASS)
-public @interface AccessedByNative {
-}
\ No newline at end of file
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java
deleted file mode 100755
index 1595f80..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @CalledByNative is used by the JNI generator to create the necessary JNI
- * bindings and expose this method to native code.
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface CalledByNative {
- /*
- * If present, tells which inner class the method belongs to.
- */
- public String value() default "";
-}
\ No newline at end of file
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java
deleted file mode 100755
index dbd1add..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.exceptions;
-
-public class IjkMediaException extends Exception {
- private static final long serialVersionUID = 7234796519009099506L;
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/ffmpeg/FFmpegApi.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/ffmpeg/FFmpegApi.java
deleted file mode 100755
index e13ba1b..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/ffmpeg/FFmpegApi.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package tv.danmaku.ijk.media.player.ffmpeg;
-
-public class FFmpegApi {
- public static native String av_base64_encode(byte in[]);
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFormatOption.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFormatOption.java
deleted file mode 100755
index 929359a..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFormatOption.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.option;
-
-@Deprecated
-public interface AvFormatOption {
- public abstract String getName();
-
- public abstract String getValue();
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFourCC.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFourCC.java
deleted file mode 100755
index cff1c5d..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/AvFourCC.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.option;
-
-@Deprecated
-public class AvFourCC {
- public static int SDL_FCC_YV12 = 0x32315659; // YV12
- public static int SDL_FCC_RV16 = 0x36315652; // RGB565
- public static int SDL_FCC_RV32 = 0x32335652; // RGBX8888
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/format/AvFormatOption_HttpDetectRangeSupport.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/option/format/AvFormatOption_HttpDetectRangeSupport.java
deleted file mode 100755
index 727552a..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/option/format/AvFormatOption_HttpDetectRangeSupport.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.option.format;
-
-import tv.danmaku.ijk.media.player.option.AvFormatOption;
-
-// some video servers do not accept "Range: bytes=0-"
-public final class AvFormatOption_HttpDetectRangeSupport implements
- AvFormatOption {
- public static AvFormatOption_HttpDetectRangeSupport Enable = new AvFormatOption_HttpDetectRangeSupport(
- "1");
- public static AvFormatOption_HttpDetectRangeSupport Disable = new AvFormatOption_HttpDetectRangeSupport(
- "0");
- private final String mValue;
-
- public AvFormatOption_HttpDetectRangeSupport(String value) {
- mValue = value;
- }
-
- public String getName() {
- return "http-detect-range-support";
- }
-
- public String getValue() {
- return mValue;
- }
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java
deleted file mode 100755
index fe3382e..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.player.pragma;
-
-import java.util.Locale;
-
-
-import android.util.Log;
-
-public class DebugLog {
- public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
-
- public static int e(String tag, String msg) {
- if (ENABLE_ERROR) {
- return Log.e(tag, msg);
- }
-
- return 0;
- }
-
- public static int e(String tag, String msg, Throwable tr) {
- if (ENABLE_ERROR) {
- return Log.e(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int efmt(String tag, String fmt, Object... args) {
- if (ENABLE_ERROR) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.e(tag, msg);
- }
-
- return 0;
- }
-
- public static int i(String tag, String msg) {
- if (ENABLE_INFO) {
- return Log.i(tag, msg);
- }
-
- return 0;
- }
-
- public static int i(String tag, String msg, Throwable tr) {
- if (ENABLE_INFO) {
- return Log.i(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int ifmt(String tag, String fmt, Object... args) {
- if (ENABLE_INFO) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.i(tag, msg);
- }
-
- return 0;
- }
-
- public static int w(String tag, String msg) {
- if (ENABLE_WARN) {
- return Log.w(tag, msg);
- }
-
- return 0;
- }
-
- public static int w(String tag, String msg, Throwable tr) {
- if (ENABLE_WARN) {
- return Log.w(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int wfmt(String tag, String fmt, Object... args) {
- if (ENABLE_WARN) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.w(tag, msg);
- }
-
- return 0;
- }
-
- public static int d(String tag, String msg) {
- if (ENABLE_DEBUG) {
- return Log.d(tag, msg);
- }
-
- return 0;
- }
-
- public static int d(String tag, String msg, Throwable tr) {
- if (ENABLE_DEBUG) {
- return Log.d(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int dfmt(String tag, String fmt, Object... args) {
- if (ENABLE_DEBUG) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.d(tag, msg);
- }
-
- return 0;
- }
-
- public static int v(String tag, String msg) {
- if (ENABLE_VERBOSE) {
- return Log.v(tag, msg);
- }
-
- return 0;
- }
-
- public static int v(String tag, String msg, Throwable tr) {
- if (ENABLE_VERBOSE) {
- return Log.v(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int vfmt(String tag, String fmt, Object... args) {
- if (ENABLE_VERBOSE) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.v(tag, msg);
- }
-
- return 0;
- }
-
- public static void printStackTrace(Throwable e) {
- if (ENABLE_WARN) {
- e.printStackTrace();
- }
- }
-
- public static void printCause(Throwable e) {
- if (ENABLE_WARN) {
- Throwable cause = e.getCause();
- if (cause != null)
- e = cause;
-
- printStackTrace(e);
- }
- }
-}
diff --git a/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java b/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java
deleted file mode 100755
index df26120..0000000
--- a/player-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package tv.danmaku.ijk.media.player.pragma;
-
-/*-
- * configurated by app project
- */
-public class Pragma {
- public static final boolean ENABLE_VERBOSE = true;
-}
diff --git a/player-java/src/main/project.properties b/player-java/src/main/project.properties
deleted file mode 100755
index 362a0a3..0000000
--- a/player-java/src/main/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-22
-android.library=true
diff --git a/sample/build.gradle b/sample/build.gradle
index 4eed8c6..3dbb372 100755
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,18 +1,15 @@
apply plugin: 'com.android.application'
android {
- // http://tools.android.com/tech-docs/new-build-system/tips
- //noinspection GroovyAssignabilityCheck
- compileSdkVersion rootProject.ext.compileSdkVersion
- //noinspection GroovyAssignabilityCheck
- buildToolsVersion rootProject.ext.buildToolsVersion
+ compileSdkVersion 23
+ buildToolsVersion "23.0.2"
defaultConfig {
- applicationId "tv.danmaku.ijk.media.sample"
- minSdkVersion 9
- targetSdkVersion 22
- versionCode 301000
- versionName "0.3.1"
+ applicationId "com.example.zhangyang.ijktest"
+ minSdkVersion 15
+ targetSdkVersion 23
+ versionCode 1
+ versionName "1.0"
}
buildTypes {
release {
@@ -23,9 +20,8 @@ android {
}
dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- compile 'com.android.support:appcompat-v7:22.2.0'
- compile project(':player-java')
- // need API-21
- // compile project(':player-arm64')
-}
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
+ compile 'com.android.support:appcompat-v7:23.2.1'
+ compile project(':IjkplayerLib')
+}
\ No newline at end of file
diff --git a/sample/sample.iml b/sample/sample.iml
index b8e224c..461cf95 100644
--- a/sample/sample.iml
+++ b/sample/sample.iml
@@ -1,5 +1,5 @@
-
+
@@ -68,8 +68,6 @@
-
-
@@ -81,11 +79,13 @@
-
+
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/.classpath b/sample/src/main/.classpath
deleted file mode 100755
index a5918a0..0000000
--- a/sample/src/main/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/src/main/.project b/sample/src/main/.project
deleted file mode 100755
index 0a083ee..0000000
--- a/sample/src/main/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- ijkplayer-sample
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/sample/src/main/.settings/org.eclipse.jdt.core.prefs b/sample/src/main/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100755
index b080d2d..0000000
--- a/sample/src/main/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
old mode 100755
new mode 100644
index ea925d6..13f4bae
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -1,52 +1,20 @@
-
-
-
-
-
-
-
-
-
-
+ package="com.example.zhangyang.ijktest">
-
-
-
+
-
-
\ No newline at end of file
+
diff --git a/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java b/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java
new file mode 100644
index 0000000..f55cfc7
--- /dev/null
+++ b/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java
@@ -0,0 +1,46 @@
+package com.example.zhangyang.ijktest;
+
+import android.content.pm.ActivityInfo;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+
+import tv.danmaku.ijk.media.player.IjkMediaPlayer;
+import tv.danmaku.ijk.media.widget.media.AndroidMediaController;
+import tv.danmaku.ijk.media.widget.media.IjkVideoView;
+
+public class MainActivity extends AppCompatActivity {
+ IjkVideoView videoView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }
+ setContentView(R.layout.activity_main);
+
+ IjkMediaPlayer.loadLibrariesOnce(null);
+ IjkMediaPlayer.native_profileBegin("libijkplayer.so");
+ videoView = (IjkVideoView) findViewById(R.id.ijkPlayer);
+ // videoView.setBackgroundColor(Color.parseColor("#F6F6F6"));
+ // videoView.setOnErrorListener(new ErrorListener());
+ AndroidMediaController controller = new AndroidMediaController(this, false);
+ videoView.setMediaController(controller);
+ String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear3/prog_index.m3u8";
+ videoView.setVideoURI(Uri.parse(url));
+ videoView.start();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ videoView.pause();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ videoView.resume();
+ }
+}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/sample/FileListActivity.java b/sample/src/main/java/tv/danmaku/ijk/media/sample/FileListActivity.java
deleted file mode 100755
index dc15996..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/sample/FileListActivity.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package tv.danmaku.ijk.media.sample;
-
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.provider.MediaStore;
-import android.support.v4.app.LoaderManager;
-import android.support.v4.content.CursorLoader;
-import android.support.v4.content.Loader;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.support.v7.app.ActionBarActivity;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ListView;
-
-
-public class FileListActivity extends ActionBarActivity implements LoaderManager.LoaderCallbacks {
-
- ListView fileListView;
- VideoAdapter adapter;
-
- boolean sortByName = false;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_file_list);
-
- fileListView = (ListView) findViewById(R.id.fileListView);
- adapter = new VideoAdapter(this);
- fileListView.setAdapter(adapter);
- fileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, final int position, final long id) {
- Intent intent = new Intent(FileListActivity.this, VideoPlayerActivity.class);
- intent.putExtra("videoPath", adapter.getVideoPath(position));
- intent.putExtra("videoTitle", adapter.getVideoTitle(position));
- startActivity(intent);
- }
- });
-
- getSupportLoaderManager().initLoader(1, null, this);
- }
-
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_file_list, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
-
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_sort) {
- sortByName = !sortByName;
- getSupportLoaderManager().restartLoader(1, null, this);
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public Loader onCreateLoader(int id, Bundle args) {
- if (sortByName) {
- return new CursorLoader(this, MediaStore.Video.Media.getContentUri("external"), null, null, null,
- "UPPER(" + MediaStore.Video.Media.DATA + ")");
- } else {
- return new CursorLoader(this, MediaStore.Video.Media.getContentUri("external"), null, null, null,
- "UPPER(" + MediaStore.Video.Media.DISPLAY_NAME + ")");
- }
- }
-
- @Override
- public void onLoadFinished(Loader loader, Cursor data) {
- adapter.swapCursor(data);
- }
-
- @Override
- public void onLoaderReset(Loader loader) {
-
- }
-
- class VideoAdapter extends SimpleCursorAdapter {
- public VideoAdapter(Context context) {
- super(context, android.R.layout.simple_list_item_2, null,
- new String[]{MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.DATA},
- new int[]{android.R.id.text1, android.R.id.text2}, 0);
- }
-
- @Override
- public long getItemId(int position) {
- final Cursor cursor = getCursor();
- if (cursor.getCount() == 0 || position >= cursor.getCount()) {
- return 0;
- }
- cursor.moveToPosition(position);
-
- return cursor.getLong(0);
- }
-
- public String getVideoTitle(int position) {
- final Cursor cursor = getCursor();
- if (cursor.getCount() == 0) {
- return "";
- }
- cursor.moveToPosition(position);
-
- return cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));
- }
-
- public String getVideoPath(int position) {
- final Cursor cursor = getCursor();
- if (cursor.getCount() == 0) {
- return "";
- }
- cursor.moveToPosition(position);
-
- return cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
- }
- }
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/sample/VideoPlayerActivity.java b/sample/src/main/java/tv/danmaku/ijk/media/sample/VideoPlayerActivity.java
deleted file mode 100755
index 83f2c3b..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/sample/VideoPlayerActivity.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.sample;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-import tv.danmaku.ijk.media.player.IjkMediaPlayer;
-import tv.danmaku.ijk.media.widget.MediaController;
-import tv.danmaku.ijk.media.widget.VideoView;
-
-public class VideoPlayerActivity extends Activity {
- private VideoView mVideoView;
- private View mBufferingIndicator;
- private MediaController mMediaController;
-
- private String mVideoPath = "http://pili-playback.wscn.wallstcn.com/wscn/chat_51_1222023523_rebirth_wallstcn_com.m3u8?start=0&end=0";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_player);
-
- IjkMediaPlayer.loadLibrariesOnce(null);
- IjkMediaPlayer.native_profileBegin("libijkplayer.so");
-
- // mVideoPath = getIntent().getStringExtra("videoPath");
-
- Intent intent = getIntent();
- String intentAction = intent.getAction();
-/* if (!TextUtils.isEmpty(intentAction) && intentAction.equals(Intent.ACTION_VIEW)) {
- mVideoPath = intent.getDataString();
- }*/
-
- mBufferingIndicator = findViewById(R.id.buffering_indicator);
- mMediaController = new MediaController(this);
-
- mVideoView = (VideoView) findViewById(R.id.video_view);
- mVideoView.setMediaController(mMediaController);
- mVideoView.setMediaBufferingIndicator(mBufferingIndicator);
- mVideoView.setVideoPath(mVideoPath);
- mVideoView.requestFocus();
- mVideoView.start();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- IjkMediaPlayer.native_profileEnd();
- }
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/CenterLayout.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/CenterLayout.java
deleted file mode 100755
index cbf6a28..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/CenterLayout.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2012 YIXIA.COM
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.RemoteViews.RemoteView;
-
-@RemoteView
-public class CenterLayout extends ViewGroup {
- private int mPaddingLeft = 0;
- private int mPaddingRight = 0;
- private int mPaddingTop = 0;
- private int mPaddingBottom = 0;
- private int mWidth, mHeight;
-
- public CenterLayout(Context context) {
- super(context);
- }
-
- public CenterLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public CenterLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int count = getChildCount();
-
- int maxHeight = 0;
- int maxWidth = 0;
-
- measureChildren(widthMeasureSpec, heightMeasureSpec);
-
- for (int i = 0; i < count; i++) {
- View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- int childRight;
- int childBottom;
-
- CenterLayout.LayoutParams lp = (CenterLayout.LayoutParams) child.getLayoutParams();
-
- childRight = lp.x + child.getMeasuredWidth();
- childBottom = lp.y + child.getMeasuredHeight();
-
- maxWidth = Math.max(maxWidth, childRight);
- maxHeight = Math.max(maxHeight, childBottom);
- }
- }
-
- maxWidth += mPaddingLeft + mPaddingRight;
- maxHeight += mPaddingTop + mPaddingBottom;
-
- maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
- maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
-
- setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec), resolveSize(maxHeight, heightMeasureSpec));
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int count = getChildCount();
- mWidth = getMeasuredWidth();
- mHeight = getMeasuredHeight();
- for (int i = 0; i < count; i++) {
- View child = getChildAt(i);
- if (child.getVisibility() != GONE) {
- CenterLayout.LayoutParams lp = (CenterLayout.LayoutParams) child.getLayoutParams();
- int childLeft = mPaddingLeft + lp.x;
- if (lp.width > 0)
- childLeft += (int) ((mWidth - lp.width) / 2.0);
- else
- childLeft += (int) ((mWidth - child.getMeasuredWidth()) / 2.0);
- int childTop = mPaddingTop + lp.y;
- if (lp.height > 0)
- childTop += (int) ((mHeight - lp.height) / 2.0);
- else
- childTop += (int) ((mHeight - child.getMeasuredHeight()) / 2.0);
- child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight());
- }
- }
- }
-
- @Override
- protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
- return p instanceof CenterLayout.LayoutParams;
- }
-
- @Override
- protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
- return new LayoutParams(p);
- }
-
- public static class LayoutParams extends ViewGroup.LayoutParams {
- public int x;
- public int y;
-
- public LayoutParams(int width, int height, int x, int y) {
- super(width, height);
- this.x = x;
- this.y = y;
- }
-
- public LayoutParams(ViewGroup.LayoutParams source) {
- super(source);
- }
- }
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/DebugLog.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/DebugLog.java
deleted file mode 100755
index 253eb8c..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/DebugLog.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.widget;
-
-import java.util.Locale;
-import android.util.Log;
-
-public class DebugLog {
- public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
- public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
-
- public static int e(String tag, String msg) {
- if (ENABLE_ERROR) {
- return Log.e(tag, msg);
- }
-
- return 0;
- }
-
- public static int e(String tag, String msg, Throwable tr) {
- if (ENABLE_ERROR) {
- return Log.e(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int efmt(String tag, String fmt, Object... args) {
- if (ENABLE_ERROR) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.e(tag, msg);
- }
-
- return 0;
- }
-
- public static int i(String tag, String msg) {
- if (ENABLE_INFO) {
- return Log.i(tag, msg);
- }
-
- return 0;
- }
-
- public static int i(String tag, String msg, Throwable tr) {
- if (ENABLE_INFO) {
- return Log.i(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int ifmt(String tag, String fmt, Object... args) {
- if (ENABLE_INFO) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.i(tag, msg);
- }
-
- return 0;
- }
-
- public static int w(String tag, String msg) {
- if (ENABLE_WARN) {
- return Log.w(tag, msg);
- }
-
- return 0;
- }
-
- public static int w(String tag, String msg, Throwable tr) {
- if (ENABLE_WARN) {
- return Log.w(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int wfmt(String tag, String fmt, Object... args) {
- if (ENABLE_WARN) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.w(tag, msg);
- }
-
- return 0;
- }
-
- public static int d(String tag, String msg) {
- if (ENABLE_DEBUG) {
- return Log.d(tag, msg);
- }
-
- return 0;
- }
-
- public static int d(String tag, String msg, Throwable tr) {
- if (ENABLE_DEBUG) {
- return Log.d(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int dfmt(String tag, String fmt, Object... args) {
- if (ENABLE_DEBUG) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.d(tag, msg);
- }
-
- return 0;
- }
-
- public static int v(String tag, String msg) {
- if (ENABLE_VERBOSE) {
- return Log.v(tag, msg);
- }
-
- return 0;
- }
-
- public static int v(String tag, String msg, Throwable tr) {
- if (ENABLE_VERBOSE) {
- return Log.v(tag, msg, tr);
- }
-
- return 0;
- }
-
- public static int vfmt(String tag, String fmt, Object... args) {
- if (ENABLE_VERBOSE) {
- String msg = String.format(Locale.US, fmt, args);
- return Log.v(tag, msg);
- }
-
- return 0;
- }
-
- public static void printStackTrace(Throwable e) {
- if (ENABLE_WARN) {
- e.printStackTrace();
- }
- }
-
- public static void printCause(Throwable e) {
- if (ENABLE_WARN) {
- Throwable cause = e.getCause();
- if (cause != null)
- e = cause;
-
- printStackTrace(e);
- }
- }
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/MediaController.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/MediaController.java
deleted file mode 100755
index 04d428d..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/MediaController.java
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * Copyright (C) 2012 YIXIA.COM
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.widget;
-
-import java.util.Locale;
-
-import tv.danmaku.ijk.media.sample.R;
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.graphics.Rect;
-import android.media.AudioManager;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageButton;
-import android.widget.PopupWindow;
-import android.widget.ProgressBar;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-/**
- * A view containing controls for a MediaPlayer. Typically contains the buttons
- * like "Play/Pause" and a progress slider. It takes care of synchronizing the
- * controls with the state of the MediaPlayer.
- *
- * The way to use this class is to a) instantiate it programatically or b)
- * create it in your xml layout.
- *
- * a) The MediaController will create a default set of controls and put them in
- * a window floating above your application. Specifically, the controls will
- * float above the view specified with setAnchorView(). By default, the window
- * will disappear if left idle for three seconds and reappear when the user
- * touches the anchor view. To customize the MediaController's style, layout and
- * controls you should extend MediaController and override the {#link
- * {@link #makeControllerView()} method.
- *
- * b) The MediaController is a FrameLayout, you can put it in your layout xml
- * and get it through {@link #findViewById(int)}.
- *
- * NOTES: In each way, if you want customize the MediaController,
- * the SeekBar's id must be {@link R.id#mediacontroller_progress}},
- * the Play/Pause's must be {@link R.id#mediacontroller_pause},
- * current time's must be {@link R.id#mediacontroller_time_current},
- * total time's must be {@link R.id#mediacontroller_time_total},
- * file name's must be {@link R.id#mediacontroller_file_name}.
- * And your resources must have a pause_button drawable and a play_button drawable.
- *
- * Functions like show() and hide() have no effect when MediaController is
- * created in an xml layout.
- */
-public class MediaController extends FrameLayout {
- private static final String TAG = MediaController.class.getSimpleName();
-
- private MediaPlayerControl mPlayer;
- private Context mContext;
- private PopupWindow mWindow;
- private int mAnimStyle;
- private View mAnchor;
- private View mRoot;
- private ProgressBar mProgress;
- private TextView mEndTime, mCurrentTime;
- private TextView mFileName;
- private OutlineTextView mInfoView;
- private String mTitle;
- private long mDuration;
- private boolean mShowing;
- private boolean mDragging;
- private boolean mInstantSeeking = true;
- private static final int sDefaultTimeout = 3000;
- private static final int FADE_OUT = 1;
- private static final int SHOW_PROGRESS = 2;
- private boolean mFromXml = false;
- private ImageButton mPauseButton;
-
- private AudioManager mAM;
-
- public MediaController(Context context, AttributeSet attrs) {
- super(context, attrs);
- mRoot = this;
- mFromXml = true;
- initController(context);
- }
-
- public MediaController(Context context) {
- super(context);
- if (!mFromXml && initController(context))
- initFloatingWindow();
- }
-
- private boolean initController(Context context) {
- mContext = context;
- mAM = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- return true;
- }
-
- @Override
- public void onFinishInflate() {
- super.onFinishInflate();//add super to suppress warning
- if (mRoot != null)
- initControllerView(mRoot);
- }
-
- private void initFloatingWindow() {
- mWindow = new PopupWindow(mContext);
- mWindow.setFocusable(false);
- mWindow.setBackgroundDrawable(null);
- mWindow.setOutsideTouchable(true);
- mAnimStyle = android.R.style.Animation;
- }
-
- /**
- * Set the view that acts as the anchor for the control view. This can for
- * example be a VideoView, or your Activity's main view.
- *
- * @param view
- * The view to which to anchor the controller when it is visible.
- */
- public void setAnchorView(View view) {
- mAnchor = view;
- if (!mFromXml) {
- removeAllViews();
- mRoot = makeControllerView();
- mWindow.setContentView(mRoot);
- mWindow.setWidth(LayoutParams.MATCH_PARENT);
- mWindow.setHeight(LayoutParams.WRAP_CONTENT);
- }
- initControllerView(mRoot);
- }
-
- /**
- * Create the view that holds the widgets that control playback. Derived
- * classes can override this to create their own.
- *
- * @return The controller view.
- */
- protected View makeControllerView() {
- return ((LayoutInflater) mContext
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
- R.layout.mediacontroller, this);
- }
-
- private void initControllerView(View v) {
- mPauseButton = (ImageButton) v
- .findViewById(R.id.mediacontroller_pause);
- if (mPauseButton != null) {
- mPauseButton.requestFocus();
- mPauseButton.setOnClickListener(mPauseListener);
- }
-
- mProgress = (SeekBar) v.findViewById(R.id.mediacontroller_progress);
- if (mProgress != null) {
- if (mProgress instanceof SeekBar) {
- SeekBar seeker = (SeekBar) mProgress;
- seeker.setOnSeekBarChangeListener(mSeekListener);
- seeker.setThumbOffset(1);
- }
- mProgress.setMax(1000);
- }
-
- mEndTime = (TextView) v.findViewById(R.id.mediacontroller_time_total);
- mCurrentTime = (TextView) v
- .findViewById(R.id.mediacontroller_time_current);
- mFileName = (TextView) v.findViewById(R.id.mediacontroller_file_name);
- if (mFileName != null)
- mFileName.setText(mTitle);
- }
-
- public void setMediaPlayer(MediaPlayerControl player) {
- mPlayer = player;
- updatePausePlay();
- }
-
- /**
- * Control the action when the seekbar dragged by user
- *
- * @param seekWhenDragging
- * True the media will seek periodically
- */
- public void setInstantSeeking(boolean seekWhenDragging) {
- mInstantSeeking = seekWhenDragging;
- }
-
- public void show() {
- show(sDefaultTimeout);
- }
-
- /**
- * Set the content of the file_name TextView
- *
- * @param name
- */
- public void setFileName(String name) {
- mTitle = name;
- if (mFileName != null)
- mFileName.setText(mTitle);
- }
-
- /**
- * Set the View to hold some information when interact with the
- * MediaController
- *
- * @param v
- */
- public void setInfoView(OutlineTextView v) {
- mInfoView = v;
- }
-
- private void disableUnsupportedButtons() {
- try {
- if (mPauseButton != null && !mPlayer.canPause())
- mPauseButton.setEnabled(false);
- } catch (IncompatibleClassChangeError ex) {
- }
- }
-
- /**
- *
- * Change the animation style resource for this controller.
- *
- *
- *
- * If the controller is showing, calling this method will take effect only
- * the next time the controller is shown.
- *
- *
- * @param animationStyle
- * animation style to use when the controller appears and
- * disappears. Set to -1 for the default animation, 0 for no
- * animation, or a resource identifier for an explicit animation.
- *
- */
- public void setAnimationStyle(int animationStyle) {
- mAnimStyle = animationStyle;
- }
-
- /**
- * Show the controller on screen. It will go away automatically after
- * 'timeout' milliseconds of inactivity.
- *
- * @param timeout
- * The timeout in milliseconds. Use 0 to show the controller
- * until hide() is called.
- */
- @SuppressLint("InlinedApi")
- public void show(int timeout) {
- if (!mShowing && mAnchor != null && mAnchor.getWindowToken() != null) {
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
- mAnchor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
- }
- if (mPauseButton != null)
- mPauseButton.requestFocus();
- disableUnsupportedButtons();
-
- if (mFromXml) {
- setVisibility(View.VISIBLE);
- } else {
- int[] location = new int[2];
-
- mAnchor.getLocationOnScreen(location);
- Rect anchorRect = new Rect(location[0], location[1],
- location[0] + mAnchor.getWidth(), location[1]
- + mAnchor.getHeight());
-
- mWindow.setAnimationStyle(mAnimStyle);
- mWindow.showAtLocation(mAnchor, Gravity.BOTTOM,
- anchorRect.left, 0);
- }
- mShowing = true;
- if (mShownListener != null)
- mShownListener.onShown();
- }
- updatePausePlay();
- mHandler.sendEmptyMessage(SHOW_PROGRESS);
-
- if (timeout != 0) {
- mHandler.removeMessages(FADE_OUT);
- mHandler.sendMessageDelayed(mHandler.obtainMessage(FADE_OUT),
- timeout);
- }
- }
-
- public boolean isShowing() {
- return mShowing;
- }
-
- @SuppressLint("InlinedApi")
- public void hide() {
- if (mAnchor == null)
- return;
-
- if (mShowing) {
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
- mAnchor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
- }
- try {
- mHandler.removeMessages(SHOW_PROGRESS);
- if (mFromXml)
- setVisibility(View.GONE);
- else
- mWindow.dismiss();
- } catch (IllegalArgumentException ex) {
- DebugLog.d(TAG, "MediaController already removed");
- }
- mShowing = false;
- if (mHiddenListener != null)
- mHiddenListener.onHidden();
- }
- }
-
- public interface OnShownListener {
- public void onShown();
- }
-
- private OnShownListener mShownListener;
-
- public void setOnShownListener(OnShownListener l) {
- mShownListener = l;
- }
-
- public interface OnHiddenListener {
- public void onHidden();
- }
-
- private OnHiddenListener mHiddenListener;
-
- public void setOnHiddenListener(OnHiddenListener l) {
- mHiddenListener = l;
- }
-
- @SuppressLint("HandlerLeak")
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- long pos;
- switch (msg.what) {
- case FADE_OUT:
- hide();
- break;
- case SHOW_PROGRESS:
- pos = setProgress();
- if (!mDragging && mShowing) {
- msg = obtainMessage(SHOW_PROGRESS);
- sendMessageDelayed(msg, 1000 - (pos % 1000));
- updatePausePlay();
- }
- break;
- }
- }
- };
-
- private long setProgress() {
- if (mPlayer == null || mDragging)
- return 0;
-
- int position = mPlayer.getCurrentPosition();
- int duration = mPlayer.getDuration();
- if (mProgress != null) {
- if (duration > 0) {
- long pos = 1000L * position / duration;
- mProgress.setProgress((int) pos);
- }
- int percent = mPlayer.getBufferPercentage();
- mProgress.setSecondaryProgress(percent * 10);
- }
-
- mDuration = duration;
-
- if (mEndTime != null)
- mEndTime.setText(generateTime(mDuration));
- if (mCurrentTime != null)
- mCurrentTime.setText(generateTime(position));
-
- return position;
- }
-
- private static String generateTime(long position) {
- int totalSeconds = (int) ((position / 1000.0)+0.5);
-
- int seconds = totalSeconds % 60;
- int minutes = (totalSeconds / 60) % 60;
- int hours = totalSeconds / 3600;
-
- if (hours > 0) {
- return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes,
- seconds).toString();
- } else {
- return String.format(Locale.US, "%02d:%02d", minutes, seconds)
- .toString();
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- show(sDefaultTimeout);
- return true;
- }
-
- @Override
- public boolean onTrackballEvent(MotionEvent ev) {
- show(sDefaultTimeout);
- return false;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- int keyCode = event.getKeyCode();
- if (event.getRepeatCount() == 0
- && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
- || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
- doPauseResume();
- show(sDefaultTimeout);
- if (mPauseButton != null)
- mPauseButton.requestFocus();
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
- if (mPlayer.isPlaying()) {
- mPlayer.pause();
- updatePausePlay();
- }
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_BACK
- || keyCode == KeyEvent.KEYCODE_MENU) {
- hide();
- return true;
- } else {
- show(sDefaultTimeout);
- }
- return super.dispatchKeyEvent(event);
- }
-
- private View.OnClickListener mPauseListener = new View.OnClickListener() {
- public void onClick(View v) {
- doPauseResume();
- show(sDefaultTimeout);
- }
- };
-
- private void updatePausePlay() {
- if (mRoot == null || mPauseButton == null)
- return;
-
- if (mPlayer.isPlaying())
- mPauseButton
- .setImageResource(R.drawable.mediacontroller_pause_button);
- else
- mPauseButton
- .setImageResource(R.drawable.mediacontroller_play_button);
- }
-
- private void doPauseResume() {
- if (mPlayer.isPlaying())
- mPlayer.pause();
- else
- mPlayer.start();
- updatePausePlay();
- }
-
- private Runnable lastRunnable;
- private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
- public void onStartTrackingTouch(SeekBar bar) {
- mDragging = true;
- show(3600000);
- mHandler.removeMessages(SHOW_PROGRESS);
- if (mInstantSeeking)
- mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
- if (mInfoView != null) {
- mInfoView.setText("");
- mInfoView.setVisibility(View.VISIBLE);
- }
- }
-
- public void onProgressChanged(SeekBar bar, int progress,
- boolean fromuser) {
- if (!fromuser)
- return;
-
- final long newposition = (mDuration * progress) / 1000;
- String time = generateTime(newposition);
- if (mInstantSeeking) {
- mHandler.removeCallbacks(lastRunnable);
- lastRunnable = new Runnable() {
- @Override
- public void run() {
- mPlayer.seekTo(newposition);
- }
- };
- mHandler.postDelayed(lastRunnable, 200);
- }
- if (mInfoView != null)
- mInfoView.setText(time);
- if (mCurrentTime != null)
- mCurrentTime.setText(time);
- }
-
- public void onStopTrackingTouch(SeekBar bar) {
- if (!mInstantSeeking)
- mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);
- if (mInfoView != null) {
- mInfoView.setText("");
- mInfoView.setVisibility(View.GONE);
- }
- show(sDefaultTimeout);
- mHandler.removeMessages(SHOW_PROGRESS);
- mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
- mDragging = false;
- mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
- }
- };
-
- @Override
- public void setEnabled(boolean enabled) {
- if (mPauseButton != null)
- mPauseButton.setEnabled(enabled);
- if (mProgress != null)
- mProgress.setEnabled(enabled);
- disableUnsupportedButtons();
- super.setEnabled(enabled);
- }
-
- public interface MediaPlayerControl {
- void start();
-
- void pause();
-
- int getDuration();
-
- int getCurrentPosition();
-
- void seekTo(long pos);
-
- boolean isPlaying();
-
- int getBufferPercentage();
-
- boolean canPause();
-
- boolean canSeekBackward();
-
- boolean canSeekForward();
- }
-
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/Pragma.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/Pragma.java
deleted file mode 100755
index 0eb7a4e..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/Pragma.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2013 Zhang Rui
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.widget;
-
-/*-
- * configurated by app project
- */
-public class Pragma {
- public static final boolean ENABLE_VERBOSE = tv.danmaku.ijk.media.player.pragma.Pragma.ENABLE_VERBOSE;
-}
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/ScreenResolution.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/ScreenResolution.java
deleted file mode 100755
index 42cf5ba..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/ScreenResolution.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * Copyright (C) 2013 YIXIA.COM
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package tv.danmaku.ijk.media.widget;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.os.Build;
-import android.util.DisplayMetrics;
-import android.util.Pair;
-import android.view.Display;
-import android.view.WindowManager;
-
-import java.lang.reflect.Method;
-
-/**
- * Class to get the real screen resolution includes the system status bar.
- * We can get the value by calling the getRealMetrics method if API >= 17
- * Reflection needed on old devices..
- * */
-public class ScreenResolution {
- /**
- * Gets the resolution,
- * @return a pair to return the width and height
- * */
- public static Pair getResolution(Context ctx){
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- return getRealResolution(ctx);
- }
- else {
- return getRealResolutionOnOldDevice(ctx);
- }
- }
-
- /**
- * Gets resolution on old devices.
- * Tries the reflection to get the real resolution first.
- * Fall back to getDisplayMetrics if the above method failed.
- * */
- private static Pair getRealResolutionOnOldDevice(Context ctx) {
- try{
- WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
- Display display = wm.getDefaultDisplay();
- Method mGetRawWidth = Display.class.getMethod("getRawWidth");
- Method mGetRawHeight = Display.class.getMethod("getRawHeight");
- Integer realWidth = (Integer) mGetRawWidth.invoke(display);
- Integer realHeight = (Integer) mGetRawHeight.invoke(display);
- return new Pair(realWidth, realHeight);
- }
- catch (Exception e) {
- DisplayMetrics disp = ctx.getResources().getDisplayMetrics();
- return new Pair(disp.widthPixels, disp.heightPixels);
- }
- }
-
- /**
- * Gets real resolution via the new getRealMetrics API.
- * */
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
- private static Pair getRealResolution(Context ctx) {
- WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
- Display display = wm.getDefaultDisplay();
- DisplayMetrics metrics = new DisplayMetrics();
- display.getRealMetrics(metrics);
- return new Pair(metrics.widthPixels, metrics.heightPixels);
- }
-}
\ No newline at end of file
diff --git a/sample/src/main/java/tv/danmaku/ijk/media/widget/VideoView.java b/sample/src/main/java/tv/danmaku/ijk/media/widget/VideoView.java
deleted file mode 100755
index 85778a2..0000000
--- a/sample/src/main/java/tv/danmaku/ijk/media/widget/VideoView.java
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * Copyright (C) 2012 YIXIA.COM
- * Copyright (C) 2013 Zhang Rui
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tv.danmaku.ijk.media.widget;
-
-import java.io.IOException;
-import java.util.List;
-
-import tv.danmaku.ijk.media.player.IMediaPlayer;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnBufferingUpdateListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnCompletionListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnErrorListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnInfoListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnPreparedListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnSeekCompleteListener;
-import tv.danmaku.ijk.media.player.IMediaPlayer.OnVideoSizeChangedListener;
-import tv.danmaku.ijk.media.player.IjkMediaPlayer;
-import tv.danmaku.ijk.media.player.option.AvFourCC;
-import tv.danmaku.ijk.media.player.option.format.AvFormatOption_HttpDetectRangeSupport;
-import tv.danmaku.ijk.media.sample.R;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.media.AudioManager;
-import android.net.Uri;
-import android.util.AttributeSet;
-import android.util.Pair;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-
-/**
- * Displays a video file. The VideoView class can load images from various
- * sources (such as resources or content providers), takes care of computing its
- * measurement from the video so that it can be used in any layout manager, and
- * provides various display options such as scaling and tinting.
- *
- * VideoView also provide many wrapper methods for
- * {@link io.vov.vitamio.MediaPlayer}, such as {@link #getVideoWidth()},
- * {@link #setSubShown(boolean)}
- */
-public class VideoView extends SurfaceView implements
- MediaController.MediaPlayerControl {
- private static final String TAG = VideoView.class.getName();
-
- private Uri mUri;
- private long mDuration;
- private String mUserAgent;
-
- private static final int STATE_ERROR = -1;
- private static final int STATE_IDLE = 0;
- private static final int STATE_PREPARING = 1;
- private static final int STATE_PREPARED = 2;
- private static final int STATE_PLAYING = 3;
- private static final int STATE_PAUSED = 4;
- private static final int STATE_PLAYBACK_COMPLETED = 5;
- private static final int STATE_SUSPEND = 6;
- private static final int STATE_RESUME = 7;
- private static final int STATE_SUSPEND_UNSUPPORTED = 8;
-
- private int mCurrentState = STATE_IDLE;
- private int mTargetState = STATE_IDLE;
-
- private int mVideoLayout = VIDEO_LAYOUT_SCALE;
- public static final int VIDEO_LAYOUT_ORIGIN = 0;
- public static final int VIDEO_LAYOUT_SCALE = 1;
- public static final int VIDEO_LAYOUT_STRETCH = 2;
- public static final int VIDEO_LAYOUT_ZOOM = 3;
-
- private SurfaceHolder mSurfaceHolder = null;
- private IMediaPlayer mMediaPlayer = null;
- private int mVideoWidth;
- private int mVideoHeight;
- private int mVideoSarNum;
- private int mVideoSarDen;
- private int mSurfaceWidth;
- private int mSurfaceHeight;
- private MediaController mMediaController;
- private View mMediaBufferingIndicator;
- private OnCompletionListener mOnCompletionListener;
- private OnPreparedListener mOnPreparedListener;
- private OnErrorListener mOnErrorListener;
- private OnSeekCompleteListener mOnSeekCompleteListener;
- private OnInfoListener mOnInfoListener;
- private OnBufferingUpdateListener mOnBufferingUpdateListener;
- private int mCurrentBufferPercentage;
- private long mSeekWhenPrepared;
- private boolean mCanPause = true;
- private boolean mCanSeekBack = true;
- private boolean mCanSeekForward = true;
- private Context mContext;
-
- public VideoView(Context context) {
- super(context);
- initVideoView(context);
- }
-
- public VideoView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public VideoView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initVideoView(context);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int width = getDefaultSize(mVideoWidth, widthMeasureSpec);
- int height = getDefaultSize(mVideoHeight, heightMeasureSpec);
- setMeasuredDimension(width, height);
- }
-
- /**
- * Set the display options
- *
- * @param layout
- *
- * - {@link #VIDEO_LAYOUT_ORIGIN}
- *
- {@link #VIDEO_LAYOUT_SCALE}
- *
- {@link #VIDEO_LAYOUT_STRETCH}
- *
- {@link #VIDEO_LAYOUT_ZOOM}
- *
- * @param aspectRatio
- * video aspect ratio, will audo detect if 0.
- */
- public void setVideoLayout(int layout) {
- LayoutParams lp = getLayoutParams();
- Pair res = ScreenResolution.getResolution(mContext);
- int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
- float windowRatio = windowWidth / (float) windowHeight;
- int sarNum = mVideoSarNum;
- int sarDen = mVideoSarDen;
- if (mVideoHeight > 0 && mVideoWidth > 0) {
- float videoRatio = ((float) (mVideoWidth)) / mVideoHeight;
- if (sarNum > 0 && sarDen > 0)
- videoRatio = videoRatio * sarNum / sarDen;
- mSurfaceHeight = mVideoHeight;
- mSurfaceWidth = mVideoWidth;
-
- if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth
- && mSurfaceHeight < windowHeight) {
- lp.width = (int) (mSurfaceHeight * videoRatio);
- lp.height = mSurfaceHeight;
- } else if (layout == VIDEO_LAYOUT_ZOOM) {
- lp.width = windowRatio > videoRatio ? windowWidth
- : (int) (videoRatio * windowHeight);
- lp.height = windowRatio < videoRatio ? windowHeight
- : (int) (windowWidth / videoRatio);
- } else {
- boolean full = layout == VIDEO_LAYOUT_STRETCH;
- lp.width = (full || windowRatio < videoRatio) ? windowWidth
- : (int) (videoRatio * windowHeight);
- lp.height = (full || windowRatio > videoRatio) ? windowHeight
- : (int) (windowWidth / videoRatio);
- }
- setLayoutParams(lp);
- getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
- DebugLog.dfmt(
- TAG,
- "VIDEO: %dx%dx%f[SAR:%d:%d], Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f",
- mVideoWidth, mVideoHeight, videoRatio, mVideoSarNum,
- mVideoSarDen, mSurfaceWidth, mSurfaceHeight, lp.width,
- lp.height, windowWidth, windowHeight, windowRatio);
- }
- mVideoLayout = layout;
- }
-
- private void initVideoView(Context ctx) {
- mContext = ctx;
- mVideoWidth = 0;
- mVideoHeight = 0;
- mVideoSarNum = 0;
- mVideoSarDen = 0;
- getHolder().addCallback(mSHCallback);
- setFocusable(true);
- setFocusableInTouchMode(true);
- requestFocus();
- mCurrentState = STATE_IDLE;
- mTargetState = STATE_IDLE;
- if (ctx instanceof Activity)
- ((Activity) ctx).setVolumeControlStream(AudioManager.STREAM_MUSIC);
- }
-
- public boolean isValid() {
- return (mSurfaceHolder != null && mSurfaceHolder.getSurface().isValid());
- }
-
- public void setVideoPath(String path) {
- setVideoURI(Uri.parse(path));
- }
-
- public void setVideoURI(Uri uri) {
- mUri = uri;
- mSeekWhenPrepared = 0;
- openVideo();
- requestLayout();
- invalidate();
- }
-
- public void setUserAgent(String ua) {
- mUserAgent = ua;
- }
-
- public void stopPlayback() {
- if (mMediaPlayer != null) {
- mMediaPlayer.stop();
- mMediaPlayer.release();
- mMediaPlayer = null;
- mCurrentState = STATE_IDLE;
- mTargetState = STATE_IDLE;
- }
- }
-
- private void openVideo() {
- if (mUri == null || mSurfaceHolder == null)
- return;
-
- Intent i = new Intent("com.android.music.musicservicecommand");
- i.putExtra("command", "pause");
- mContext.sendBroadcast(i);
-
- release(false);
- try {
- mDuration = -1;
- mCurrentBufferPercentage = 0;
- IjkMediaPlayer ijkMediaPlayer = null;
- if (mUri != null) {
- ijkMediaPlayer = new IjkMediaPlayer();
-
- ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "overlay-format", IjkMediaPlayer.SDL_FCC_RV32);
- ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 12);
-
- ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "http-detect-range-support", 0);
- ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "user_agent", mUserAgent);
-
- ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);
- }
- mMediaPlayer = ijkMediaPlayer;
- mMediaPlayer.setOnPreparedListener(mPreparedListener);
- mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
- mMediaPlayer.setOnCompletionListener(mCompletionListener);
- mMediaPlayer.setOnErrorListener(mErrorListener);
- mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
- mMediaPlayer.setOnInfoListener(mInfoListener);
- mMediaPlayer.setOnSeekCompleteListener(mSeekCompleteListener);
- if (mUri != null)
- mMediaPlayer.setDataSource(mUri.toString());
- mMediaPlayer.setDisplay(mSurfaceHolder);
- mMediaPlayer.setScreenOnWhilePlaying(true);
- mMediaPlayer.prepareAsync();
- mCurrentState = STATE_PREPARING;
- attachMediaController();
- } catch (IOException ex) {
- DebugLog.e(TAG, "Unable to open content: " + mUri, ex);
- mCurrentState = STATE_ERROR;
- mTargetState = STATE_ERROR;
- mErrorListener.onError(mMediaPlayer,
- IMediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
- return;
- } catch (IllegalArgumentException ex) {
- DebugLog.e(TAG, "Unable to open content: " + mUri, ex);
- mCurrentState = STATE_ERROR;
- mTargetState = STATE_ERROR;
- mErrorListener.onError(mMediaPlayer,
- IMediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
- return;
- }
- }
-
- public void setMediaController(MediaController controller) {
- if (mMediaController != null)
- mMediaController.hide();
- mMediaController = controller;
- attachMediaController();
- }
-
- public void setMediaBufferingIndicator(View mediaBufferingIndicator) {
- if (mMediaBufferingIndicator != null)
- mMediaBufferingIndicator.setVisibility(View.GONE);
- mMediaBufferingIndicator = mediaBufferingIndicator;
- }
-
- private void attachMediaController() {
- if (mMediaPlayer != null && mMediaController != null) {
- mMediaController.setMediaPlayer(this);
- View anchorView = this.getParent() instanceof View ? (View) this
- .getParent() : this;
- mMediaController.setAnchorView(anchorView);
- mMediaController.setEnabled(isInPlaybackState());
-
- if (mUri != null) {
- List paths = mUri.getPathSegments();
- String name = paths == null || paths.isEmpty() ? "null" : paths
- .get(paths.size() - 1);
- mMediaController.setFileName(name);
- }
- }
- }
-
- OnVideoSizeChangedListener mSizeChangedListener = new OnVideoSizeChangedListener() {
- public void onVideoSizeChanged(IMediaPlayer mp, int width, int height,
- int sarNum, int sarDen) {
- DebugLog.dfmt(TAG, "onVideoSizeChanged: (%dx%d)", width, height);
- mVideoWidth = mp.getVideoWidth();
- mVideoHeight = mp.getVideoHeight();
- mVideoSarNum = sarNum;
- mVideoSarDen = sarDen;
- if (mVideoWidth != 0 && mVideoHeight != 0)
- setVideoLayout(mVideoLayout);
- }
- };
-
- OnPreparedListener mPreparedListener = new OnPreparedListener() {
- public void onPrepared(IMediaPlayer mp) {
- DebugLog.d(TAG, "onPrepared");
- mCurrentState = STATE_PREPARED;
- mTargetState = STATE_PLAYING;
-
- if (mOnPreparedListener != null)
- mOnPreparedListener.onPrepared(mMediaPlayer);
- if (mMediaController != null)
- mMediaController.setEnabled(true);
- mVideoWidth = mp.getVideoWidth();
- mVideoHeight = mp.getVideoHeight();
-
- long seekToPosition = mSeekWhenPrepared;
-
- if (seekToPosition != 0)
- seekTo(seekToPosition);
- if (mVideoWidth != 0 && mVideoHeight != 0) {
- setVideoLayout(mVideoLayout);
- if (mSurfaceWidth == mVideoWidth
- && mSurfaceHeight == mVideoHeight) {
- if (mTargetState == STATE_PLAYING) {
- start();
- if (mMediaController != null)
- mMediaController.show();
- } else if (!isPlaying()
- && (seekToPosition != 0 || getCurrentPosition() > 0)) {
- if (mMediaController != null)
- mMediaController.show(0);
- }
- }
- } else if (mTargetState == STATE_PLAYING) {
- start();
- }
- }
- };
-
- private OnCompletionListener mCompletionListener = new OnCompletionListener() {
- public void onCompletion(IMediaPlayer mp) {
- DebugLog.d(TAG, "onCompletion");
- mCurrentState = STATE_PLAYBACK_COMPLETED;
- mTargetState = STATE_PLAYBACK_COMPLETED;
- if (mMediaController != null)
- mMediaController.hide();
- if (mOnCompletionListener != null)
- mOnCompletionListener.onCompletion(mMediaPlayer);
- }
- };
-
- private OnErrorListener mErrorListener = new OnErrorListener() {
- public boolean onError(IMediaPlayer mp, int framework_err, int impl_err) {
- DebugLog.dfmt(TAG, "Error: %d, %d", framework_err, impl_err);
- mCurrentState = STATE_ERROR;
- mTargetState = STATE_ERROR;
- if (mMediaController != null)
- mMediaController.hide();
-
- if (mOnErrorListener != null) {
- if (mOnErrorListener.onError(mMediaPlayer, framework_err,
- impl_err))
- return true;
- }
-
- if (getWindowToken() != null) {
- int message = framework_err == IMediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK ? R.string.vitamio_videoview_error_text_invalid_progressive_playback
- : R.string.vitamio_videoview_error_text_unknown;
-
- new AlertDialog.Builder(mContext)
- .setTitle(R.string.vitamio_videoview_error_title)
- .setMessage(message)
- .setPositiveButton(
- R.string.vitamio_videoview_error_button,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- if (mOnCompletionListener != null)
- mOnCompletionListener
- .onCompletion(mMediaPlayer);
- }
- }).setCancelable(false).show();
- }
- return true;
- }
- };
-
- private OnBufferingUpdateListener mBufferingUpdateListener = new OnBufferingUpdateListener() {
- public void onBufferingUpdate(IMediaPlayer mp, int percent) {
- mCurrentBufferPercentage = percent;
- if (mOnBufferingUpdateListener != null)
- mOnBufferingUpdateListener.onBufferingUpdate(mp, percent);
- }
- };
-
- private OnInfoListener mInfoListener = new OnInfoListener() {
- @Override
- public boolean onInfo(IMediaPlayer mp, int what, int extra) {
- DebugLog.dfmt(TAG, "onInfo: (%d, %d)", what, extra);
- if (mOnInfoListener != null) {
- mOnInfoListener.onInfo(mp, what, extra);
- } else if (mMediaPlayer != null) {
- if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_START) {
- DebugLog.dfmt(TAG, "onInfo: (MEDIA_INFO_BUFFERING_START)");
- if (mMediaBufferingIndicator != null)
- mMediaBufferingIndicator.setVisibility(View.VISIBLE);
- } else if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_END) {
- DebugLog.dfmt(TAG, "onInfo: (MEDIA_INFO_BUFFERING_END)");
- if (mMediaBufferingIndicator != null)
- mMediaBufferingIndicator.setVisibility(View.GONE);
- }
- }
-
- return true;
- }
- };
-
- private OnSeekCompleteListener mSeekCompleteListener = new OnSeekCompleteListener() {
- @Override
- public void onSeekComplete(IMediaPlayer mp) {
- DebugLog.d(TAG, "onSeekComplete");
- if (mOnSeekCompleteListener != null)
- mOnSeekCompleteListener.onSeekComplete(mp);
- }
- };
-
- public void setOnPreparedListener(OnPreparedListener l) {
- mOnPreparedListener = l;
- }
-
- public void setOnCompletionListener(OnCompletionListener l) {
- mOnCompletionListener = l;
- }
-
- public void setOnErrorListener(OnErrorListener l) {
- mOnErrorListener = l;
- }
-
- public void setOnBufferingUpdateListener(OnBufferingUpdateListener l) {
- mOnBufferingUpdateListener = l;
- }
-
- public void setOnSeekCompleteListener(OnSeekCompleteListener l) {
- mOnSeekCompleteListener = l;
- }
-
- public void setOnInfoListener(OnInfoListener l) {
- mOnInfoListener = l;
- }
-
- SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback() {
- public void surfaceChanged(SurfaceHolder holder, int format, int w,
- int h) {
- mSurfaceHolder = holder;
- if (mMediaPlayer != null) {
- mMediaPlayer.setDisplay(mSurfaceHolder);
- }
-
- mSurfaceWidth = w;
- mSurfaceHeight = h;
- boolean isValidState = (mTargetState == STATE_PLAYING);
- boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h);
- if (mMediaPlayer != null && isValidState && hasValidSize) {
- if (mSeekWhenPrepared != 0)
- seekTo(mSeekWhenPrepared);
- start();
- if (mMediaController != null) {
- if (mMediaController.isShowing())
- mMediaController.hide();
- mMediaController.show();
- }
- }
- }
-
- public void surfaceCreated(SurfaceHolder holder) {
- mSurfaceHolder = holder;
- if (mMediaPlayer != null && mCurrentState == STATE_SUSPEND
- && mTargetState == STATE_RESUME) {
- mMediaPlayer.setDisplay(mSurfaceHolder);
- resume();
- } else {
- openVideo();
- }
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- mSurfaceHolder = null;
- if (mMediaController != null)
- mMediaController.hide();
- if (mCurrentState != STATE_SUSPEND)
- release(true);
- }
- };
-
- private void release(boolean cleartargetstate) {
- if (mMediaPlayer != null) {
- mMediaPlayer.reset();
- mMediaPlayer.release();
- mMediaPlayer = null;
- mCurrentState = STATE_IDLE;
- if (cleartargetstate)
- mTargetState = STATE_IDLE;
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- if (isInPlaybackState() && mMediaController != null)
- toggleMediaControlsVisiblity();
- return false;
- }
-
- @Override
- public boolean onTrackballEvent(MotionEvent ev) {
- if (isInPlaybackState() && mMediaController != null)
- toggleMediaControlsVisiblity();
- return false;
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK
- && keyCode != KeyEvent.KEYCODE_VOLUME_UP
- && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
- && keyCode != KeyEvent.KEYCODE_MENU
- && keyCode != KeyEvent.KEYCODE_CALL
- && keyCode != KeyEvent.KEYCODE_ENDCALL;
- if (isInPlaybackState() && isKeyCodeSupported
- && mMediaController != null) {
- if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
- || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
- || keyCode == KeyEvent.KEYCODE_SPACE) {
- if (mMediaPlayer.isPlaying()) {
- pause();
- mMediaController.show();
- } else {
- start();
- mMediaController.hide();
- }
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
- && mMediaPlayer.isPlaying()) {
- pause();
- mMediaController.show();
- } else {
- toggleMediaControlsVisiblity();
- }
- }
-
- return super.onKeyDown(keyCode, event);
- }
-
- private void toggleMediaControlsVisiblity() {
- if (mMediaController.isShowing()) {
- mMediaController.hide();
- } else {
- mMediaController.show();
- }
- }
-
- @Override
- public void start() {
- if (isInPlaybackState()) {
- mMediaPlayer.start();
- mCurrentState = STATE_PLAYING;
- }
- mTargetState = STATE_PLAYING;
- }
-
- @Override
- public void pause() {
- if (isInPlaybackState()) {
- if (mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
- mCurrentState = STATE_PAUSED;
- }
- }
- mTargetState = STATE_PAUSED;
- }
-
- public void resume() {
- if (mSurfaceHolder == null && mCurrentState == STATE_SUSPEND) {
- mTargetState = STATE_RESUME;
- } else if (mCurrentState == STATE_SUSPEND_UNSUPPORTED) {
- openVideo();
- }
- }
-
- @Override
- public int getDuration() {
- if (isInPlaybackState()) {
- if (mDuration > 0)
- return (int) mDuration;
- mDuration = mMediaPlayer.getDuration();
- return (int) mDuration;
- }
- mDuration = -1;
- return (int) mDuration;
- }
-
- @Override
- public int getCurrentPosition() {
- if (isInPlaybackState()) {
- long position = mMediaPlayer.getCurrentPosition();
- return (int) position;
- }
- return 0;
- }
-
- @Override
- public void seekTo(long msec) {
- if (isInPlaybackState()) {
- mMediaPlayer.seekTo(msec);
- mSeekWhenPrepared = 0;
- } else {
- mSeekWhenPrepared = msec;
- }
- }
-
- @Override
- public boolean isPlaying() {
- return isInPlaybackState() && mMediaPlayer.isPlaying();
- }
-
- @Override
- public int getBufferPercentage() {
- if (mMediaPlayer != null)
- return mCurrentBufferPercentage;
- return 0;
- }
-
- public int getVideoWidth() {
- return mVideoWidth;
- }
-
- public int getVideoHeight() {
- return mVideoHeight;
- }
-
- protected boolean isInPlaybackState() {
- return (mMediaPlayer != null && mCurrentState != STATE_ERROR
- && mCurrentState != STATE_IDLE && mCurrentState != STATE_PREPARING);
- }
-
- public boolean canPause() {
- return mCanPause;
- }
-
- public boolean canSeekBackward() {
- return mCanSeekBack;
- }
-
- public boolean canSeekForward() {
- return mCanSeekForward;
- }
-}
diff --git a/sample/src/main/jniLibs/armeabi-v7a/libijkplayer.so b/sample/src/main/jniLibs/armeabi-v7a/libijkplayer.so
deleted file mode 100755
index 31e3bee..0000000
Binary files a/sample/src/main/jniLibs/armeabi-v7a/libijkplayer.so and /dev/null differ
diff --git a/sample/src/main/jniLibs/armeabi-v7a/libijksdl.so b/sample/src/main/jniLibs/armeabi-v7a/libijksdl.so
deleted file mode 100755
index 7b7b31a..0000000
Binary files a/sample/src/main/jniLibs/armeabi-v7a/libijksdl.so and /dev/null differ
diff --git a/sample/src/main/jniLibs/armeabi/libijkplayer.so b/sample/src/main/jniLibs/armeabi/libijkplayer.so
deleted file mode 100755
index 4c400e1..0000000
Binary files a/sample/src/main/jniLibs/armeabi/libijkplayer.so and /dev/null differ
diff --git a/sample/src/main/jniLibs/armeabi/libijksdl.so b/sample/src/main/jniLibs/armeabi/libijksdl.so
deleted file mode 100755
index 79c8c8a..0000000
Binary files a/sample/src/main/jniLibs/armeabi/libijksdl.so and /dev/null differ
diff --git a/sample/src/main/jniLibs/x86/libijkplayer.so b/sample/src/main/jniLibs/x86/libijkplayer.so
deleted file mode 100755
index 57daad1..0000000
Binary files a/sample/src/main/jniLibs/x86/libijkplayer.so and /dev/null differ
diff --git a/sample/src/main/jniLibs/x86/libijksdl.so b/sample/src/main/jniLibs/x86/libijksdl.so
deleted file mode 100755
index da19863..0000000
Binary files a/sample/src/main/jniLibs/x86/libijksdl.so and /dev/null differ
diff --git a/sample/src/main/project.properties b/sample/src/main/project.properties
deleted file mode 100755
index 672cae7..0000000
--- a/sample/src/main/project.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-22
-android.library.reference.1=../../../player-arm64/src/main
-android.library.reference.2=../../../player-armv5/src/main
-android.library.reference.3=../../../player-armv7a/src/main
-android.library.reference.4=../../../player-x86/src/main
-android.library.reference.5=../../../player-java/src/main
-android.library.reference.6=../../../../contrib/appcompat
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_bg.png b/sample/src/main/res/drawable-hdpi/mediacontroller_bg.png
deleted file mode 100755
index 63b9aa5..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_bg.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_pause01.png b/sample/src/main/res/drawable-hdpi/mediacontroller_pause01.png
deleted file mode 100755
index 698277a..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_pause01.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_pause02.png b/sample/src/main/res/drawable-hdpi/mediacontroller_pause02.png
deleted file mode 100755
index d954a0e..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_pause02.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_play01.png b/sample/src/main/res/drawable-hdpi/mediacontroller_play01.png
deleted file mode 100755
index 81bcb26..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_play01.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_play02.png b/sample/src/main/res/drawable-hdpi/mediacontroller_play02.png
deleted file mode 100755
index 67100f8..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_play02.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar01.png b/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar01.png
deleted file mode 100755
index 8bcdcab..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar01.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar02.png b/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar02.png
deleted file mode 100755
index b7fd9dd..0000000
Binary files a/sample/src/main/res/drawable-hdpi/mediacontroller_seekbar02.png and /dev/null differ
diff --git a/sample/src/main/res/drawable/mediacontroller_pause_button.xml b/sample/src/main/res/drawable/mediacontroller_pause_button.xml
deleted file mode 100755
index ec96825..0000000
--- a/sample/src/main/res/drawable/mediacontroller_pause_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/drawable/mediacontroller_play_button.xml b/sample/src/main/res/drawable/mediacontroller_play_button.xml
deleted file mode 100755
index eb91676..0000000
--- a/sample/src/main/res/drawable/mediacontroller_play_button.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_file_list.xml b/sample/src/main/res/layout/activity_file_list.xml
deleted file mode 100755
index 343304d..0000000
--- a/sample/src/main/res/layout/activity_file_list.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..0e49162
--- /dev/null
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/sample/src/main/res/layout/activity_player.xml b/sample/src/main/res/layout/activity_player.xml
deleted file mode 100755
index d49b9a9..0000000
--- a/sample/src/main/res/layout/activity_player.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/layout/mediacontroller.xml b/sample/src/main/res/layout/mediacontroller.xml
deleted file mode 100755
index 193c2ce..0000000
--- a/sample/src/main/res/layout/mediacontroller.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/menu/menu_file_list.xml b/sample/src/main/res/menu/menu_file_list.xml
deleted file mode 100755
index 5d40ea4..0000000
--- a/sample/src/main/res/menu/menu_file_list.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher.png b/sample/src/main/res/mipmap-hdpi/ic_launcher.png
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/src/main/res/mipmap-mdpi/ic_launcher.png
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/sample/src/main/res/values-v11/styles.xml b/sample/src/main/res/values-v11/styles.xml
deleted file mode 100755
index 3c02242..0000000
--- a/sample/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/sample/src/main/res/values-v14/styles.xml b/sample/src/main/res/values-v14/styles.xml
deleted file mode 100755
index a91fd03..0000000
--- a/sample/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/sample/src/main/res/values-w820dp/dimens.xml b/sample/src/main/res/values-w820dp/dimens.xml
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
old mode 100755
new mode 100644
index 327c060..3ab3e9c
--- a/sample/src/main/res/values/colors.xml
+++ b/sample/src/main/res/values/colors.xml
@@ -1,5 +1,6 @@
+
-
- #66000000
-
+ #3F51B5
+ #303F9F
+ #FF4081
diff --git a/sample/src/main/res/values/dimens.xml b/sample/src/main/res/values/dimens.xml
old mode 100755
new mode 100644
diff --git a/sample/src/main/res/values/ids.xml b/sample/src/main/res/values/ids.xml
deleted file mode 100755
index 644e796..0000000
--- a/sample/src/main/res/values/ids.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
old mode 100755
new mode 100644
index 1a5ebb9..f6bd621
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -1,20 +1,3 @@
-
-
- ijkmediademo
- Dummy Button
- DUMMY\nCONTENT
-
- buffering
- Sort
-
- Vitamio
- Initializing decoders…
- Cannot play video
- Sorry, this video is not valid for streaming to
- this device.
- Sorry, this video cannot be played.
- OK
- Play/Pause
-
+ IjkTest
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
old mode 100755
new mode 100644
index ddf92f1..5885930
--- a/sample/src/main/res/values/styles.xml
+++ b/sample/src/main/res/values/styles.xml
@@ -1,31 +1,11 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/settings.gradle b/settings.gradle
index 2273e71..a58b5fd 100755
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':sample', ':player-java'
+include ':sample', ':IjkplayerLib'