package org.libsdl.app;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import android.app.*;
import android.content.*;
import android.view.*;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsoluteLayout;
import android.os.*;
import android.util.Log;
import android.graphics.*;
import android.media.*;
import android.hardware.*;
/**
SDL Activity
*/
public class SDLActivity extends Activity {
private static final String TAG = "SDL";
// Keep track of the paused state
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus;
public static boolean mExitCalledFromJava;
// Main components
protected static SDLActivity mSingleton;
protected static SDLSurface mSurface;
protected static View mTextEdit;
protected static ViewGroup mLayout;
protected static SDLJoystickHandler mJoystickHandler;
// This is what SDL runs in. It invokes SDL_main(), eventually
protected static Thread mSDLThread;
// Audio
protected static AudioTrack mAudioTrack;
// Load the .so
static {
System.loadLibrary("SDL2");
//System.loadLibrary("SDL2_image");
//System.loadLibrary("SDL2_mixer");
//System.loadLibrary("SDL2_net");
//System.loadLibrary("SDL2_ttf");
System.loadLibrary("SDL2main");
}
public static void initialize() {
// The static nature of the singleton and Android quirkyness force us to initialize everything here
// Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values
mSingleton = null;
mSurface = null;
mTextEdit = null;
mLayout = null;
mJoystickHandler = null;
mSDLThread = null;
mAudioTrack = null;
mExitCalledFromJava = false;
mIsPaused = false;
mIsSurfaceReady = false;
mHasFocus = true;
}
// Setup
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v("SDL", "onCreate():" + mSingleton);
super.onCreate(savedInstanceState);
SDLActivity.initialize();
// So we can call stuff from static callbacks
mSingleton = this;
// Set up the surface
mSurface = new SDLSurface(getApplication());
if(Build.VERSION.SDK_INT >= 12) {
mJoystickHandler = new SDLJoystickHandler_API12();
}
else {
mJoystickHandler = new SDLJoystickHandler();
}
mLayout = new AbsoluteLayout(this);
mLayout.addView(mSurface);
setContentView(mLayout);
}
// Events
@Override
protected void onPause() {
Log.v("SDL", "onPause()");
super.onPause();
SDLActivity.handlePause();
}
@Override
protected void onResume() {
Log.v("SDL", "onResume()");
super.onResume();
SDLActivity.handleResume();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);
SDLActivity.mHasFocus = hasFocus;
if (hasFocus) {
SDLActivity.handleResume();
}
}
@Override
public void onLowMemory() {
Log.v("SDL", "onLowMemory()");
super.onLowMemory();
SDLActivity.nativeLowMemory();
}
@Override
protected void onDestroy() {
Log.v("SDL", "onDestroy()");
// Send a quit message to the application
SDLActivity.mExitCalledFromJava = true;
SDLActivity.nativeQuit();
// Now wait for the SDL thread to quit
if (SDLActivity.mSDLThread != null) {
try {
SDLActivity.mSDLThread.join();
} catch(Exception e) {
Log.v("SDL", "Problem stopping thread: " + e);
}
SDLActivity.mSDLThread = null;
//Log.v("SDL", "Finished waiting for SDL thread");
}
super.onDestroy();
// Reset everything in case the user re opens the app
SDLActivity.initialize();
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
// Ignore certain special keys so they're handled by Android
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
keyCode == KeyEvent.KEYCODE_CAMERA ||
keyCode == 168 || /* API 11: KeyEvent.KEYCODE_ZOOM_IN */
keyCode == 169 /* API 11: KeyEvent.KEYCODE_ZOOM_OUT */
) {
return false;
}
return super.dispatchKeyEvent(event);
}
/** Called by onPause or surfaceDestroyed. Even if surfaceDestroyed
* is the first to be called, mIsSurfaceReady should still be set
* to 'true' during the call to onPause (in a usual scenario).
*/
public static void handlePause() {
if (!SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady) {
SDLActivity.mIsPaused = true;
SDLActivity.nativePause();
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, false);
}
}
/** Called by onResume or surfaceCreated. An actual resume should be done only when the surface is ready.
* Note: Some Android variants may send multiple surfaceChanged events, so we don't need to resume
* every time we get one of those events, only if it comes after surfaceDestroyed
*/
public static void handleResume() {
if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
SDLActivity.mIsPaused = false;
SDLActivity.nativeResume();
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
}
}
/* The native thread has finished */
public static void handleNativeExit() {
SDLActivity.mSDLThread = null;
mSingleton.finish();
}
// Messages from the SDLMain thread
static final int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_UNUSED = 2;
static final int COMMAND_TEXTEDIT_HIDE = 3;
protected static final int COMMAND_USER = 0x8000;
/**
* This method is called by SDL if SDL did not handle a message itself.
* This happens if a received message contains an unsupported command.
* Method can be overwritten to handle Messages in a different class.
* @param command the command of the message.
* @param param the parameter of the message. May be null.
* @return if the message was handled in overridden method.
*/
protected boolean onUnhandledMessage(int command, Object param) {
return false;
}
/**
* A Handler class for Messages from native SDL applications.
* It uses current Activities as target (e.g. for the title).
* static to prevent implicit references to enclosing object.
*/
protected static class SDLCommandHandler extends Handler {
@Override
public void handleMessage(Message msg) {
Context context = getContext();
if (context == null) {
Log.e(TAG, "error handling message, getContext() returned null");
return;
}
switch (msg.arg1) {
case COMMAND_CHANGE_TITLE:
if (context instanceof Activity) {
((Activity) context).setTitle((String)msg.obj);
} else {
Lo
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本解决方案包含了使用FFmpeg在移动端处理多媒体的各种例子: [Android] simplest_android_player: 基于安卓接口的视频播放器 simplest_ffmpeg_android_helloworld: 安卓平台下基于FFmpeg的HelloWorld程序 simplest_ffmpeg_android_decoder: 安卓平台下最简单的基于FFmpeg的视频解码器 simplest_ffmpeg_android_decoder_onelib: 安卓平台下最简单的基于FFmpeg的视频解码器-单库版 simplest_ffmpeg_android_streamer: 安卓平台下最简单的基于FFmpeg的推流器 simplest_ffmpeg_android_transcoder: 安卓平台下移植的FFmpeg命令行工具 simplest_sdl_android_helloworld: 移植SDL到安卓平台的最简单程序 [IOS] simplest_ios_player: 基于IOS接口的视频播放器 simplest_ffmpeg_ios_helloworld: IOS平台下基于FFmpeg的HelloWorld程序 simplest_ffmpeg_ios_decoder: IOS平台下最简单的基于FFmpeg的视频解码器 simplest_ffmpeg_ios_streamer: IOS平台下最简单的基于FFmpeg的推流器 simplest_ffmpeg_ios_transcoder: IOS平台下移植的ffmpeg.c命令行工具 simplest_sdl_ios_helloworld: 移植SDL到IOS平台的最简单程序
资源推荐
资源详情
资源评论
收起资源包目录
最简单的基于FFmpeg的移动端例子 (1998个子文件)
libavfilter.a 48.94MB
libavfilter.a 48.94MB
libavfilter.a 48.94MB
libavfilter.a 48.94MB
libavcodec.a 32.74MB
libavcodec.a 32.74MB
libavcodec.a 32.74MB
libavcodec.a 32.74MB
libx264.a 14.57MB
libx264.a 14.57MB
libx264.a 14.57MB
libx264.a 14.57MB
libavformat.a 13.49MB
libavformat.a 13.49MB
libavformat.a 13.49MB
libavformat.a 13.49MB
libswscale.a 5.24MB
libswscale.a 5.24MB
libswscale.a 5.24MB
libswscale.a 5.24MB
libavutil.a 3.31MB
libavutil.a 3.31MB
libavutil.a 3.31MB
libavutil.a 3.31MB
libswresample.a 1004KB
libswresample.a 1004KB
libswresample.a 1004KB
libswresample.a 1004KB
libavdevice.a 555KB
libavdevice.a 555KB
libavdevice.a 555KB
libavdevice.a 555KB
libfaac.a 548KB
libfaac.a 548KB
libfaac.a 548KB
libfaac.a 548KB
libpostproc.a 503KB
libpostproc.a 503KB
libpostproc.a 503KB
libpostproc.a 503KB
resources.ap_ 66KB
resources.ap_ 66KB
resources.ap_ 66KB
resources.ap_ 19KB
SFFmpegAndroidDecoder.apk 4.55MB
SFFmpegAndroidHelloworld.apk 4.55MB
SDLActivity.apk 351KB
SAndroidPlayer.apk 298KB
test.bmp 469KB
SDL_audiotypecvt.c 620KB
SDL_blit_auto.c 282KB
SDL_test_imageBlitBlend.c 210KB
SDL_malloc.c 193KB
ffmpeg_mod.c 150KB
ffmpeg_mod.c 150KB
ffmpeg_opt.c 129KB
ffmpeg_opt.c 126KB
SDL_render_d3d11.c 115KB
SDL_test_imageBlit.c 114KB
SDL_blit_N.c 93KB
SDL_video.c 89KB
SDL_test_font.c 86KB
cmdutils.c 73KB
cmdutils.c 72KB
SDL_dxjoystick.c 68KB
SDL_render_gles2.c 65KB
SDL_render_d3d.c 62KB
SDL_RLEaccel.c 55KB
SDL_syshaptic.c 54KB
SDL_render.c 54KB
SDL_test_common.c 54KB
SDL_android.c 54KB
SDL_windowskeyboard.c 52KB
SDL_test_imagePrimitivesBlend.c 51KB
SDL_render_gl.c 51KB
SDL_x11window.c 49KB
SDL_yuv_sw.c 45KB
SDL_DirectFB_render.c 44KB
SDL_blit_A.c 44KB
SDL_string.c 43KB
SDL_gamecontroller.c 41KB
SDL_syshaptic.c 40KB
ffmpeg_filter.c 40KB
SDL_audio.c 39KB
ffmpeg_filter.c 38KB
SDL_x11events.c 38KB
SDL_render_gles.c 37KB
SDL_test_imagePrimitives.c 37KB
SDL_audiocvt.c 37KB
SDL_shaders_gles2.c 36KB
SDL_windowsevents.c 34KB
SDL_evdev.c 33KB
SDL_pixels.c 32KB
SDL_syshaptic.c 32KB
SDL_surface.c 31KB
SDL_x11modes.c 30KB
SDL_iconv.c 29KB
SDL_DirectFB_events.c 29KB
SDL_render_psp.c 28KB
SDL_x11opengl.c 28KB
共 1998 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
雷霄骅
- 粉丝: 4w+
- 资源: 141
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页