Commit 6ea6a37d by 徐健

冥想模块编写完成

parent 76b30390
...@@ -169,6 +169,7 @@ dependencies { ...@@ -169,6 +169,7 @@ dependencies {
//开发模式 //开发模式
api project(':m-consultant') api project(':m-consultant')
api project(':m-user') api project(':m-user')
api project(':m-muse')
api (project(':ydl-platform')){ api (project(':ydl-platform')){
transitive = true transitive = true
} }
...@@ -179,6 +180,7 @@ dependencies { ...@@ -179,6 +180,7 @@ dependencies {
api 'com.ydl:m-user-module-ydl:0.0.6' api 'com.ydl:m-user-module-ydl:0.0.6'
api rootProject.ext.dependencies["ydl-webview"] api rootProject.ext.dependencies["ydl-webview"]
api rootProject.ext.dependencies["ydl-m-user-api"] api rootProject.ext.dependencies["ydl-m-user-api"]
api rootProject.ext.dependencies["ydl-m-muse-api"]
api(rootProject.ext.dependencies["ydl-platform"]) { api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true transitive = true
} }
......
...@@ -17,8 +17,10 @@ import com.ydl.component.music.MusicPlayActivity ...@@ -17,8 +17,10 @@ import com.ydl.component.music.MusicPlayActivity
import com.ydl.component.mvp.DemoContract import com.ydl.component.mvp.DemoContract
import com.ydl.component.mvp.DemoPresenter import com.ydl.component.mvp.DemoPresenter
import com.ydl.media.audio.PlayService import com.ydl.media.audio.PlayService
import com.ydl.media.view.PlayerFloatHelper import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.ExpertSearchActivity.Companion.HOT_SEARCH_DOCTOR_NAME import com.yidianling.consultant.ExpertSearchActivity.Companion.HOT_SEARCH_DOCTOR_NAME
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
...@@ -74,8 +76,31 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -74,8 +76,31 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
bt_to_music.setOnClickListener { bt_to_music.setOnClickListener {
startActivity(Intent(this, MusicPlayActivity::class.java)) startActivity(Intent(this, MusicPlayActivity::class.java))
} }
bt_to_muse.setOnClickListener {
YDLRouterManager.router(IYDLRouterConstant.ROUTER_MUSE,
YDLRouterParams().putExtra(IYDLRouterConstant.MUSIC_URL, "http://video.yidianling.com/2019/05/30/e6d4a71e8c895f2156a2ff37d93ca3a9.mp3")
.putExtra(IYDLRouterConstant.DATA_JSON, "{\n" +
" \"muses\": [{\n" +
" \"id\": 6,\n" +
" \"name\": \"冥想基础介绍-1-什么是冥想?\",\n" +
" \"audioUrl\":\n" +
" \"http://video.yidianling.com/2019/05/30/e6d4a71e8c895f2156a2ff37d93ca3a9.mp3\",\n" +
" \"backgroundUrl\":\n" +
" \"https://img.yidianling.com/file/2019/06/10/i4qdax82ok2aizq3.png\",\n" +
" \"effectCode\": 1,\n" +
" \"category\": 2,\n" +
" \"playCount\": 929,\n" +
" \"sort\": 255,\n" +
" \"isDelete\": 1,\n" +
" \"createTime\": \"May 30, 2019 4:45:17 PM\",\n" +
" \"updateTime\": \"Jun 10, 2019 7:14:23 PM\"\n" +
" }]\n" +
" }"))
}
} }
override fun loadData() { override fun loadData() {
mPresenter?.loadUsers() mPresenter?.loadUsers()
} }
......
...@@ -89,7 +89,8 @@ ...@@ -89,7 +89,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="horizontal">
<Button <Button
android:id="@+id/bt_to_music" android:id="@+id/bt_to_music"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -97,6 +98,14 @@ ...@@ -97,6 +98,14 @@
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:text="Jump to Musci" /> android:text="Jump to Musci" />
<Button
android:id="@+id/bt_to_muse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:text="Jump to 冥想" />
</LinearLayout> </LinearLayout>
......
...@@ -158,7 +158,7 @@ ext { ...@@ -158,7 +158,7 @@ ext {
"ydl-pushagent" : 'com.ydl:ydl-pushagent:0.1.8', "ydl-pushagent" : 'com.ydl:ydl-pushagent:0.1.8',
"ydl-notracepoint" : 'com.ydl:notracepoint-lib:0.1.8@aar', "ydl-notracepoint" : 'com.ydl:notracepoint-lib:0.1.8@aar',
"ydl-js" : 'com.ydl:ydl-js:1.0.7-SNAPSHOT@aar', "ydl-js" : 'com.ydl:ydl-js:1.0.7-SNAPSHOT@aar',
"ydl-router" : 'com.ydl:ydl-router:1.3.0-SNAPSHOT@aar', "ydl-router" : 'com.ydl:ydl-router:1.3.2-SNAPSHOT@aar',
"xrecyclerview" : 'com.ydl:xrecyclerview:1.0.0-SNAPSHOT@aar', "xrecyclerview" : 'com.ydl:xrecyclerview:1.0.0-SNAPSHOT@aar',
"arouter-api" : "com.alibaba:arouter-api:1.4.1", "arouter-api" : "com.alibaba:arouter-api:1.4.1",
"arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2", "arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2",
...@@ -174,6 +174,7 @@ ext { ...@@ -174,6 +174,7 @@ ext {
"ydl-user-router" : 'com.ydl:router:1.0.0-SNAPSHOT@aar', "ydl-user-router" : 'com.ydl:router:1.0.0-SNAPSHOT@aar',
"ydl-platform" : 'com.ydl:ydl-platform:0.0.10@aar', "ydl-platform" : 'com.ydl:ydl-platform:0.0.10@aar',
"ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5', "ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5',
"ydl-webview" : 'com.ydl:ydl-webview:0.0.14@aar' "ydl-webview" : 'com.ydl:ydl-webview:0.0.14@aar',
"ydl-m-muse-api" : 'com.ydl:m-muse-api:0.0.1@aar'
] ]
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
kapt { kapt {
arguments { arguments {
arg("AROUTER_MODULE_NAME", project.getName()) arg("AROUTER_MODULE_NAME", project.getName())
...@@ -10,21 +10,23 @@ kapt { ...@@ -10,21 +10,23 @@ kapt {
} }
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig { defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
flavorDimensions "versionCode" flavorDimensions "versionCode"
javaCompileOptions { }
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"] lintOptions {
} abortOnError false
}
} }
buildTypes { buildTypes {
...@@ -34,6 +36,13 @@ android { ...@@ -34,6 +36,13 @@ android {
} }
} }
//Flavor 信息
publishNonDefault true
productFlavors {
ydl {}
xlzx {}
}
compileOptions { compileOptions {
sourceCompatibility 1.8 sourceCompatibility 1.8
targetCompatibility 1.8 targetCompatibility 1.8
...@@ -49,9 +58,14 @@ dependencies { ...@@ -49,9 +58,14 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
if (rootProject.ext.dev_mode){ if (rootProject.ext.dev_mode){
//开发时使用 //开发时使用
api project(":ydl-platform") api project(":ydl-platform")
implementation project(':ydl-media')
} else { } else {
//发布时使用 //发布时使用
api(rootProject.ext.dependencies["ydl-platform"]) { api(rootProject.ext.dependencies["ydl-platform"]) {
......
...@@ -5,7 +5,6 @@ import com.ydl.media.audio.AudioPlayer ...@@ -5,7 +5,6 @@ import com.ydl.media.audio.AudioPlayer
import com.ydl.ydlcommon.base.flutter.base.BaseFlutterActivity import com.ydl.ydlcommon.base.flutter.base.BaseFlutterActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.muse.handler.MusePlugin import com.yidianling.muse.handler.MusePlugin
import com.yidianling.ydlcommon.flutter.base.BaseFlutterActivity
import org.json.JSONObject import org.json.JSONObject
...@@ -27,8 +26,7 @@ class MuseActivity : BaseFlutterActivity() { ...@@ -27,8 +26,7 @@ class MuseActivity : BaseFlutterActivity() {
* 如果正在播放音乐,则停止播放所有音乐 * 如果正在播放音乐,则停止播放所有音乐
*/ */
if (AudioPlayer.get().isPlaying) { if (AudioPlayer.get().isPlaying) {
AudioPlayer.get().playMode/**playingType*/ = YDLMusicHelper.PLAY_TYPE_MUSE AudioPlayer.get().stopPlayer()
YDLMusicHelper.stop()
} }
} }
...@@ -37,6 +35,6 @@ class MuseActivity : BaseFlutterActivity() { ...@@ -37,6 +35,6 @@ class MuseActivity : BaseFlutterActivity() {
/** /**
* 退出冥想模块的时候,关闭音乐播放 * 退出冥想模块的时候,关闭音乐播放
*/ */
YDLMusicHelper.stop() AudioPlayer.get().stopPlayer()
} }
} }
...@@ -2,9 +2,12 @@ package com.yidianling.muse.handler ...@@ -2,9 +2,12 @@ package com.yidianling.muse.handler
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.view.dialog.YDLShareDialog import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.muse.R
import com.yidianling.muse.api.bean.MuseModuleBean import com.yidianling.muse.api.bean.MuseModuleBean
import io.flutter.app.FlutterActivity import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodCall
...@@ -65,18 +68,25 @@ class MusePlugin : MethodChannel.MethodCallHandler { ...@@ -65,18 +68,25 @@ class MusePlugin : MethodChannel.MethodCallHandler {
var mContinue: Boolean = methodCall.argument<Boolean>("mContinue")!! var mContinue: Boolean = methodCall.argument<Boolean>("mContinue")!!
if (mContinue) { if (mContinue) {
YDLMusicHelper.seekTo(YDLMusicHelper.time) AudioPlayer.get().seekTo(-1, AudioPlayer.get().audioPosition)
AudioPlayer.get().startPlayer()
}else { }else {
YDLMusicHelper.musePlay(musicUrl ?: currentMusicUrl) val music = Music()
music.path = musicUrl ?: currentMusicUrl
music.album = ""
music.artist = ""
music.coverPath = ""
music.title = ""
AudioPlayer.get().singleCirclePlay(music)
} }
} }
// 暂停音乐 // 暂停音乐
ACTION_PAUSE_MUSIC -> { ACTION_PAUSE_MUSIC -> {
YDLMusicHelper.pause() AudioPlayer.get().pausePlayer()
} }
// 暂停(销毁)音乐 // 暂停(销毁)音乐
ACTION_STOP_MUSIC -> { ACTION_STOP_MUSIC -> {
YDLMusicHelper.stop() AudioPlayer.get().stopPlayer()
} }
// 设置默认时间 // 设置默认时间
ACTION_SET_DEFAULT_TIME -> { ACTION_SET_DEFAULT_TIME -> {
......
include ':app',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview', ':ydl-media',":m-user", ':m-consultant', ':m-tests', ':m-muse' include ':app',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview', ':ydl-media',":m-user", ':m-consultant', ':m-muse'
\ No newline at end of file \ No newline at end of file
...@@ -199,6 +199,17 @@ class AudioPlayer private constructor() { ...@@ -199,6 +199,17 @@ class AudioPlayer private constructor() {
} }
/** /**
* 单曲循环模式播放音乐
*/
fun singleCirclePlay(music: Music) {
musicList.clear()
musicList.add(music)
playMode = PlayModeEnum.SINGLE_LOOP
autoSaveProgress = false
play(0)
}
/**
* 添加后自动播放 * 添加后自动播放
*/ */
fun addAndPlay(music: Music) { fun addAndPlay(music: Music) {
...@@ -346,6 +357,7 @@ class AudioPlayer private constructor() { ...@@ -346,6 +357,7 @@ class AudioPlayer private constructor() {
} }
pausePlayer() pausePlayer()
musicList.clear()
mediaPlayer!!.reset() mediaPlayer!!.reset()
state = STATE_IDLE state = STATE_IDLE
} }
......
...@@ -8,6 +8,7 @@ import com.ydl.ydlcommon.base.config.IApp ...@@ -8,6 +8,7 @@ import com.ydl.ydlcommon.base.config.IApp
import com.ydl.ydlcommon.base.delegate.AppDelegate import com.ydl.ydlcommon.base.delegate.AppDelegate
import com.ydl.ydlcommon.base.delegate.IAppLifecycles import com.ydl.ydlcommon.base.delegate.IAppLifecycles
import com.ydl.ydlcommon.utils.YDLPreconditions import com.ydl.ydlcommon.utils.YDLPreconditions
import io.flutter.view.FlutterMain
/** /**
* Created by haorui on 2019-08-21 . * Created by haorui on 2019-08-21 .
...@@ -45,6 +46,10 @@ open class BaseApp : Application(), IApp { ...@@ -45,6 +46,10 @@ open class BaseApp : Application(), IApp {
super.onCreate() super.onCreate()
if (mAppDelegate != null) if (mAppDelegate != null)
this.mAppDelegate!!.onCreate(this) this.mAppDelegate!!.onCreate(this)
//Flutter 初始化需要在主线程中执行
FlutterMain.startInitialization(this)
} }
/** /**
......
...@@ -32,6 +32,8 @@ interface IYDLRouterConstant{ ...@@ -32,6 +32,8 @@ interface IYDLRouterConstant{
const val ROUTER_ANSWERS_HOME = ROUTER_BASE + "answers/home" const val ROUTER_ANSWERS_HOME = ROUTER_BASE + "answers/home"
//话题详情页 //话题详情页
const val ROUTER_TOPIC_DETAIL = ROUTER_BASE + "topic/detail" const val ROUTER_TOPIC_DETAIL = ROUTER_BASE + "topic/detail"
//冥想页面
const val ROUTER_MUSE = ROUTER_BASE + "module/muse"
//fm列表页 //fm列表页
const val ROUTER_FM_LIST = ROUTER_BASE + "fm/list" const val ROUTER_FM_LIST = ROUTER_BASE + "fm/list"
//fm详情页 //fm详情页
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment