Skip to content
Open
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
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.19.3",
"flavors": {}
}
30 changes: 9 additions & 21 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
buildscript {

ext.kotlin_version = '1.5.32'
ext.exo_player_version = '2.18.5'

repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

group 'me.sithiramunasinghe.flutter.flutter_radio_player'
version '1.0-SNAPSHOT'

Expand All @@ -29,7 +13,8 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
namespace 'me.sithiramunasinghe.flutter.flutter_radio_player'
compileSdkVersion 36

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -52,14 +37,17 @@ android {


dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

implementation "org.greenrobot:eventbus:3.3.1"
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.google.code.gson:gson:2.10.1'

implementation "androidx.multidex:multidex:2.0.1"

implementation "com.google.android.exoplayer:exoplayer:$exo_player_version"
ext.exo_player_version = '2.18.5'
implementation "com.google.android.exoplayer:exoplayer-core:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-ui:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-hls:$exo_player_version"
implementation "com.google.android.exoplayer:extension-mediasession:$exo_player_version"
}
}
1 change: 0 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
26 changes: 26 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0" // apply true
id "com.android.application" version "8.12.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
}

include ":app"

rootProject.name = 'flutter_radio_player'
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
private val GSON = Gson()
}

var serviceIntent: Intent? = null

private var isBound: Boolean = false
private var context: Context? = null
private var pluginActivity: Activity? = null
Expand All @@ -56,7 +54,6 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
frpChannel?.setMethodCallHandler(null)
frpChannel = null
eventSink = null
serviceIntent = null
}

override fun onAttachedToActivity(binding: ActivityPluginBinding) {
Expand All @@ -82,10 +79,9 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
}

private fun onAttachedToEngine(context: Context, binaryMessenger: BinaryMessenger) {
Log.i(TAG, "::: Attaching to FRP to FlutterEngine :::")
Log.i(TAG, "::: Attaching FRP to FlutterEngine :::")
this.context = context
frpChannel = MethodChannel(binaryMessenger, METHOD_CHANNEL_NAME)
frpChannel?.setMethodCallHandler(this)

val eventChannel = EventChannel(binaryMessenger, EVENT_CHANNEL_NAME)
eventChannel.setStreamHandler(object : EventChannel.StreamHandler {
Expand All @@ -100,7 +96,7 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
})

// service intent
serviceIntent = Intent(context, FRPCoreService::class.java)
val serviceIntent = Intent(context, FRPCoreService::class.java)

// start the background service.
pluginActivity?.startService(serviceIntent)
Expand All @@ -121,15 +117,18 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
isBound = false
}
}
Log.i(TAG, "Binding service...")
flutterPluginBinding?.applicationContext?.bindService(serviceIntent, serviceConnection!!, Context.BIND_AUTO_CREATE)

context.bindService(serviceIntent, serviceConnection!!, Context.BIND_AUTO_CREATE)
frpChannel?.setMethodCallHandler(this)
}

@Subscribe(threadMode = ThreadMode.MAIN)
fun handleFRPEvents(event: FRPPlayerEvent) {
if (eventSink != null) {
Log.d(TAG, "FRP Event data = $event")
if (event.playbackStatus != null) {
// TODO reconsider unbinding service on stop because it might be too cumbersome to rebind it when resuming
if (event.playbackStatus == FRP_STOPPED) {
Log.i(TAG, "Service unbind....")
isBound = false
Expand All @@ -152,6 +151,7 @@ class FlutterRadioPlayerPlugin : FlutterPlugin, ActivityAware, MethodChannel.Met
}

override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
Log.i(TAG, ":::: received method call: ${call.method} ::::")
when (call.method) {
"init_service" -> {
if (isBound) {
Expand Down
Loading