播放功能优化
This commit is contained in:
parent
c62e38eb7e
commit
7349c58e6d
@ -17,8 +17,7 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
//com.hi.music.player
|
||||
applicationId = "com.offline.music.playermp3"
|
||||
applicationId = "com.offline.music.playermp3.test"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:550960818622:android:96fd4141e43410fb24f1ef",
|
||||
"android_client_info": {
|
||||
"package_name": "com.offline.music.playermp3"
|
||||
"package_name": "com.offline.music.playermp3.test"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
|
||||
@ -39,6 +39,6 @@ public class Sp {
|
||||
}
|
||||
|
||||
public String getStringValue(String key) {
|
||||
return preferences.getString(key, RemoteConfigJava.value_open_type_0);
|
||||
return preferences.getString(key, RemoteConfigJava.value_open_type_1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,5 @@ public class MyPlayCacheManager {
|
||||
return playCache;
|
||||
}
|
||||
|
||||
public static SimpleCache getPlayCache() {
|
||||
return playCache;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,21 +70,11 @@ public class PlaybackService extends MediaSessionService {
|
||||
DefaultDataSource.Factory factory = new DefaultDataSource.Factory(this);
|
||||
playCache = MyPlayCacheManager.getInitPlayCache(context);
|
||||
CacheDataSource.Factory factory1 = new CacheDataSource.Factory().setCache(playCache)
|
||||
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
|
||||
.setConnectTimeoutMs(16000)
|
||||
.setReadTimeoutMs(8000)
|
||||
.setUserAgent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"))
|
||||
.setEventListener(new CacheDataSource.EventListener() {
|
||||
@Override
|
||||
public void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead) {
|
||||
CommonUtils.LogMsg("-----------缓存2 -PlayCache-" + cacheSizeBytes + "----cacheSizeBytes=" + cachedBytesRead);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheIgnored(int reason) {
|
||||
CommonUtils.LogMsg("-----------缓存2忽略 PlayCache=" + reason);
|
||||
}
|
||||
});
|
||||
.setUpstreamDataSourceFactory(factory);
|
||||
// .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
|
||||
// .setConnectTimeoutMs(16000)
|
||||
// .setReadTimeoutMs(8000)
|
||||
// .setUserAgent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"));
|
||||
downloadCache = MyDownloadService.getDownloadCache();
|
||||
return new CacheDataSource.Factory()
|
||||
.setCache(downloadCache)
|
||||
@ -113,7 +103,7 @@ public class PlaybackService extends MediaSessionService {
|
||||
|
||||
@Override
|
||||
public DataSpec resolveDataSpec(DataSpec dataSpec) {
|
||||
CommonUtils.LogMsg("--------resolveDataSpec dataSpec.key=" + dataSpec.key+"---dataSpec.uri="+dataSpec.uri);
|
||||
CommonUtils.LogMsg("--------resolveDataSpec dataSpec.key=" + dataSpec.key);
|
||||
return dataSpec;
|
||||
|
||||
// long length = 1L;
|
||||
@ -138,7 +128,7 @@ public class PlaybackService extends MediaSessionService {
|
||||
@Override
|
||||
public Uri resolveReportedUri(Uri uri) {
|
||||
CommonUtils.LogMsg("--------resolveDataSpec uri=" + uri);
|
||||
return ResolvingDataSource.Resolver.super.resolveReportedUri(Uri.parse("---"));
|
||||
return ResolvingDataSource.Resolver.super.resolveReportedUri(uri);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
musicVideoType = responseSingle.getMusicVideoType();
|
||||
mDefaultPlayStartIndex = intent.getIntExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY_LIST_INDEX, mDefaultPlayStartIndex);
|
||||
|
||||
SimpleCache playCache = MyPlayCacheManager.getPlayCache();
|
||||
|
||||
// boolean songCached = CommonUtils.isSongCached(playCache, videoId);
|
||||
|
||||
// CommonUtils.LogMsg("---------------是否有播放缓存--songCached="+songCached +"--name="+responseSingle.getSongTitle());
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingBottom="20dp"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
@ -110,7 +111,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="9999999999999999999999999999999999999999999999"
|
||||
android:text=""
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintRight_toRightOf="@id/tv_song_name"
|
||||
@ -245,6 +246,7 @@
|
||||
android:layout_width="66dp"
|
||||
android:layout_height="66dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:src="@drawable/selector_icon_play"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="22dp"
|
||||
android:layout_toStartOf="@id/frame_play"
|
||||
android:layout_toEndOf="@id/image"
|
||||
android:layout_toEndOf="@id/circular_pb"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
@ -13,6 +13,6 @@ dependencyResolutionManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "MusicApp"
|
||||
rootProject.name = "Offline Music Player"
|
||||
include(":app")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user