Skip to content
Open

test #651

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ version '0.11.0'
apply plugin: 'com.android.library'

android {
compileSdkVersion 30
compileSdkVersion 31
namespace "com.befovy.fijkplayer"

defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
targetSdkVersion 31 // 关键:与 compileSdkVersion 保持一致,避免版本脱节
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // 替换为 AndroidX 测试 runner
}

lintOptions {
disable 'InvalidPackage'
}
}

// 强制统一资源编译版本,避免冲突
resourcePrefix "fijkplayer_" // 可选:给插件资源加前缀,防止与项目资源重名
}

dependencies {

// implementation(name: 'fijkplayer-full-release', ext: 'aar')

// fijkplayer-full include the java lib and native shared libs for armv5 armv7 arm64 x86 x86_64
implementation 'com.befovy.fijkplayer:fijkplayer-full:0.7.16'
implementation 'androidx.annotation:annotation:1.2.0'
// 核心依赖:锁定低版本 core-ktx,避免传递引入 lStar 相关资源
implementation 'androidx.core:core-ktx:1.6.0'
// 升级 annotation 依赖,确保与 AndroidX 版本兼容
implementation 'androidx.annotation:annotation:1.5.0'
// 保留原 fijkplayer-full 依赖,添加强制排除冲突的 AndroidX 库
implementation('com.befovy.fijkplayer:fijkplayer-full:0.7.16') {
exclude group: 'androidx.core' // 排除库自带的 core 依赖,使用上面锁定的 1.6.0 版本
}
}
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest package="com.befovy.fijkplayer">
<manifest>

</manifest>
53 changes: 10 additions & 43 deletions android/src/main/java/com/befovy/fijkplayer/FijkPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//copies of the Software, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
Expand Down Expand Up @@ -52,16 +51,13 @@
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.view.TextureRegistry;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

/**
* FijkPlugin
*/
public class FijkPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware, FijkEngine, FijkVolume.VolumeKeyListener, AudioManager.OnAudioFocusChangeListener {
public class FijkPlugin implements MethodChannel.MethodCallHandler, FlutterPlugin, ActivityAware, FijkEngine, FijkVolume.VolumeKeyListener, AudioManager.OnAudioFocusChangeListener {

// show system volume changed UI if no playable player
// hide system volume changed UI if some players are in playable state
Expand All @@ -81,7 +77,6 @@ public class FijkPlugin implements MethodCallHandler, FlutterPlugin, ActivityAwa

private WeakReference<Activity> mActivity;
private WeakReference<Context> mContext;
private Registrar mRegistrar;
private FlutterPluginBinding mBinding;

// Count of playable players
Expand All @@ -97,21 +92,6 @@ public class FijkPlugin implements MethodCallHandler, FlutterPlugin, ActivityAwa
private boolean mAudioFocusRequested = false;


/**
* Plugin registration.
*/
@SuppressWarnings("unused")
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "befovy.com/fijk");
FijkPlugin plugin = new FijkPlugin();
plugin.initWithRegistrar(registrar);
channel.setMethodCallHandler(plugin);

final FijkPlayer player = new FijkPlayer(plugin, true);
player.setupSurface();
player.release();
}

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), "befovy.com/fijk");
Expand All @@ -132,6 +112,12 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
mContext = null;
mBinding = null;
if (mEventChannel != null) {
mEventChannel.setStreamHandler(null);
mEventSink.setDelegate(null);
mEventChannel = null;
}
}

@Override
Expand Down Expand Up @@ -167,8 +153,6 @@ public void onDetachedFromActivity() {
public TextureRegistry.SurfaceTextureEntry createSurfaceEntry() {
if (mBinding != null) {
return mBinding.getTextureRegistry().createSurfaceTexture();
} else if (mRegistrar != null) {
return mRegistrar.textures().createSurfaceTexture();
}
return null;
}
Expand All @@ -178,8 +162,6 @@ public TextureRegistry.SurfaceTextureEntry createSurfaceEntry() {
public BinaryMessenger messenger() {
if (mBinding != null) {
return mBinding.getBinaryMessenger();
} else if (mRegistrar != null) {
return mRegistrar.messenger();
}
return null;
}
Expand All @@ -195,9 +177,7 @@ public Context context() {

@Nullable
private Activity activity() {
if (mRegistrar != null) {
return mRegistrar.activity();
} else if (mActivity != null) {
if (mActivity != null) {
return mActivity.get();
} else {
return null;
Expand All @@ -215,23 +195,10 @@ public String lookupKeyForAsset(@NonNull String asset, @Nullable String packageN
//noinspection ConstantConditions
path = mBinding.getFlutterAssets().getAssetFilePathByName(asset, packageName);
}
} else if (mRegistrar != null) {
if (TextUtils.isEmpty(packageName)) {
path = mRegistrar.lookupKeyForAsset(asset);
} else {
path = mRegistrar.lookupKeyForAsset(asset, packageName);
}
}
return path;
}


private void initWithRegistrar(@NonNull Registrar registrar) {
mRegistrar = registrar;
mContext = new WeakReference<>(registrar.activeContext());
init(registrar.messenger());
}

private void initWithBinding(@NonNull FlutterPluginBinding binding) {
mBinding = binding;
mContext = new WeakReference<>(binding.getApplicationContext());
Expand Down Expand Up @@ -270,7 +237,7 @@ public void onCancel(Object o) {


@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
Activity activity;
switch (call.method) {
case "getPlatformVersion":
Expand Down