我当前获取所有Musik文件的方法是使用内容解析器和游标。现在,我已经阅读了更好的方法。我尝试使用 import pandas as pd
df1 = pd.read_excel('/.../dummy_data_examples.xlsx', sheet_name='Sheet1')
df2 = pd.read_excel('/.../refdata_examples.xlsx', sheet_name='Sheet1')
df1['price'] = df1.apply(lambda row:df2.loc[process.extract(row.Defproduto,
df2['Defproduto'],limit=1,scorer=fuzz.ratio)[0][2],].price,axis=1)
,但显然没有得到正确的输出?我的MediaBrowserCompat.MediaItem
函数是错误的还是在“主要活动”中将其称为错误?
主要活动:
onLoadChildren
服务:
package com.name.mediabrowsertest
import android.content.ComponentName
import android.content.Context
import android.content.res.Configuration
import android.media.AudioManager
import android.media.session.MediaController
import android.os.Build
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.provider.MediaStore
import android.support.annotation.RequiresApi
import android.support.v4.media.MediaBrowserCompat
import android.support.v4.media.MediaMetadataCompat
import android.support.v4.media.session.MediaControllerCompat
import android.support.v4.media.session.PlaybackStateCompat
import android.util.Log
import android.view.View
import android.widget.ImageView
class MainActivity : AppCompatActivity() {
private lateinit var mMediaBrowser: MediaBrowserCompat
fun buildTransportControls(){
var mMediaItems = mMediaBrowser.subscribe(mMediaBrowser.root,object: MediaBrowserCompat.SubscriptionCallback(){})
var mPlayPause = findViewById<ImageView>(R.id.imageView)
//Attach listen to button
mPlayPause.setOnClickListener(object: View.OnClickListener {
override fun onClick(v : View ){
var pbSate = MediaControllerCompat.getMediaController(this@MainActivity).playbackState.playbackState
if(pbSate == PlaybackStateCompat.STATE_PLAYING){
MediaControllerCompat.getMediaController(this@MainActivity).transportControls.pause()
}else{
var test = MediaBrowserCompat.MediaItem.CONTENTS_FILE_DESCRIPTOR
Log.i("TEST",test.toString())
MediaControllerCompat.getMediaController(this@MainActivity).transportControls.playFromMediaId(MediaBrowserCompat.EXTRA_MEDIA_ID,null)
MediaControllerCompat.getMediaController(this@MainActivity).transportControls.play()
//MediaControllerCompat.getMediaController(this@MainActivity).transportControls.playFromMediaId()
Log.i("TEST","TEST")
}
}
})
var mediaController = MediaControllerCompat.getMediaController(this@MainActivity)
//Show Init state
var metadat = mediaController.metadata
var pbState = mediaController.playbackState
//Register Callback to stay synced
mediaController.registerCallback(controllerCallback)
}
val controllerCallback = object : MediaControllerCompat.Callback() {
override fun onMetadataChanged(metadat:MediaMetadataCompat){
Log.i("Musik",metadat.toString())
}
override fun onPlaybackStateChanged(state :PlaybackStateCompat){}
}
private val mConnectionCallbacks = object : MediaBrowserCompat.ConnectionCallback() {
override fun onConnected() {
Log.i("Connection","Connecting")
// Get the token for the MediaSession
val token = mMediaBrowser.sessionToken
// Create a MediaControllerCompat
val mediaController = MediaControllerCompat(this@MainActivity,token)
// Save the controller
MediaControllerCompat.setMediaController(this@MainActivity, mediaController)
// Finish building the UI
buildTransportControls()
}
override fun onConnectionSuspended() {
// The Service has crashed. Disable transport controls until it automatically reconnects
Log.i("ERROR","Connection Suspended")
}
override fun onConnectionFailed() {
// The Service has refused our connection
Log.i("ERROR","Connection Failed")
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Log.i("Hello World","Hello")
//Create MediaBrowser Service
mMediaBrowser = MediaBrowserCompat(this,
ComponentName(this, MediaPlaybackService::class.java),
mConnectionCallbacks,
null)
Log.i("Hello World","Hello2")
}
override fun onStart() {
super.onStart()
mMediaBrowser.connect()
}
override fun onResume() {
super.onResume()
volumeControlStream = AudioManager.STREAM_MUSIC
}
override fun onStop() {
super.onStop()
if(MediaControllerCompat.getMediaController(this@MainActivity) != null){
MediaControllerCompat.getMediaController(this@MainActivity).unregisterCallback(controllerCallback)
}
mMediaBrowser.disconnect()
}
}