Skip to content

Commit a3b7f4a

Browse files
authored
Merge pull request #241 from tobexyz/chore/prepareRelease520
Chore/prepare release520
2 parents 4b49c5b + a936edb commit a3b7f4a

21 files changed

Lines changed: 210 additions & 51 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Version 5.2.0
22
- fixed app crash on unknown http codes in upnp responses
33
- fixed pause/play on yaacc renderer
4+
- improved media type extraction and fallback title for SAF content
5+
- server now uses the media filename or title as filename in content url
46
- allow stopping the app via action button in notification
57
- stop the app completely if idle in background

yaacc/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
4-
android:versionCode="50101"
5-
android:versionName="5.1.1-SNAPSHOT">
4+
android:versionCode="50200"
5+
android:versionName="5.2.0">
66

77
<uses-permission android:name="android.permission.INTERNET" />
88
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

yaacc/src/main/java/de/yaacc/player/AVTransportPlayer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ private void proceedWithSetURI(PlayableItem playableItem, Service<?, ?> service)
718718
String metadata;
719719
try {
720720
metadata = new DIDLParser().generate((item == null) ? new DIDLContent() : new DIDLContent().addItem(item), false);
721-
721+
String itemTitle = item != null ? item.getTitle() : "null";
722+
YaaccLogger.d(getClass().getName(), "DIDL Metadata generated - Item title: " + itemTitle + " - Metadata XML: " + metadata.substring(0, Math.min(500, metadata.length())));
722723
} catch (Exception e) {
723724
YaaccLogger.d(getClass().getName(), "Error while generating Didl-Item xml: " + e);
724725
metadata = "";
@@ -750,6 +751,7 @@ service, modifyProxyUrlWithDeviceId(playableItem.getUri().toString()), actionSta
750751
getHttpRequestSender());
751752
YaaccLogger.d(getClass().getName(), "Original URI: " + playableItem.getUri().toString());
752753
YaaccLogger.d(getClass().getName(), "Modified URI: " + modifyProxyUrlWithDeviceId(playableItem.getUri().toString()));
754+
YaaccLogger.d(getClass().getName(), "SetAVTransportURI - Title: " + (item != null ? item.getTitle() : "null") + ", Metadata length: " + metadata.length());
753755
executorService.execute(setAVTransportURI);
754756
waitForActionComplete(actionState);
755757
int tries = 1;

yaacc/src/main/java/de/yaacc/upnp/server/YaaccUpnpServerService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public void onCreate() {
187187
public void onReceive(Context context, Intent intent) {
188188
int total = intent.getIntExtra("files_indexed", 0);
189189
cacheFilesIndexed = total;
190+
cacheCurrentFolder = ""; // Clear folder when indexing completes
190191
showNotification(); // Update notification with final cache status
191192
}
192193
};
@@ -391,13 +392,20 @@ private void showNotification() {
391392

392393
// Duration cache status
393394
SAFCacheManager cacheManager = SAFCacheManager.getInstance(this);
394-
if (cacheManager.isPreloading()) {
395+
boolean isPreloading = cacheManager.isPreloading();
396+
YaaccLogger.d(getClass().getName(), "showNotification: isPreloading=" + isPreloading + ", cacheSize=" + cacheManager.getCacheSize() + ", filesIndexed=" + cacheFilesIndexed);
397+
398+
if (isPreloading) {
395399
statusBuilder.append(" | ⏳ Indexing: ").append(cacheFilesIndexed);
396400
if (!cacheCurrentFolder.isEmpty()) {
397401
statusBuilder.append(" (").append(cacheCurrentFolder).append(")");
398402
}
403+
YaaccLogger.d(getClass().getName(), "Notification: showing indexing progress - " + cacheFilesIndexed + " files");
399404
} else if (cacheManager.getCacheSize() > 0) {
400405
statusBuilder.append(" | ✓ Cache: ").append(cacheManager.getCacheSize());
406+
YaaccLogger.d(getClass().getName(), "Notification: showing cache size - " + cacheManager.getCacheSize() + " items");
407+
} else {
408+
YaaccLogger.d(getClass().getName(), "Notification: no cache or indexing (isPreloading=" + isPreloading + ", cacheSize=" + cacheManager.getCacheSize() + ")");
401409
}
402410

403411
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, Yaacc.NOTIFICATION_CHANNEL_ID)

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/ContentBrowser.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,26 @@ public String getUriString(YaaccContentDirectory contentDirectory, String id, Mi
149149
return "http://" + contentDirectory.getIpAddress() + ":"
150150
+ YaaccUpnpServerService.PORT + "/res/" + id + "/file." + fileExtension;
151151
}
152+
153+
public String getUriString(YaaccContentDirectory contentDirectory, String id, MimeType mimeType, String filename, String contentUri) {
154+
String fileExtension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType.toString());
155+
if (fileExtension == null) {
156+
fileExtension = mimeType.getSubtype();
157+
}
158+
159+
if (contentUri != null) {
160+
// SAF format with filename
161+
return "http://" + contentDirectory.getIpAddress() + ":"
162+
+ YaaccUpnpServerService.PORT + "/saf/" + id + "/" + contentUri + "." + fileExtension;
163+
}
164+
165+
// Non-SAF format with filename included for renderer title
166+
String safeFilename = filename != null && !filename.isEmpty()
167+
? filename.replaceAll("[^a-zA-Z0-9._-]", "_")
168+
: "file";
169+
return "http://" + contentDirectory.getIpAddress() + ":"
170+
+ YaaccUpnpServerService.PORT + "/res/" + id + "/" + safeFilename + "." + fileExtension;
171+
}
152172

153173
public String getDLNAAttributes(MimeType mimetype) {
154174
String mime = mimetype.toString();

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/ImageByBucketNameItemBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
8383
@SuppressLint("Range") MimeType mimeType = MimeType.valueOf(mimeTypeString);
8484
// file parameter only needed for media players which decide the
8585
// ability of playing a file by the file extension
86-
String uri = getUriString(contentDirectory, id, mimeType);
86+
String uri = getUriString(contentDirectory, id, mimeType, name, null);
8787
String albumArtUri = "http://" + contentDirectory.getIpAddress() + ":"
8888
+ YaaccUpnpServerService.PORT + "/thumb/" + id;
8989

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/ImagesAllFolderBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public List<Item> browseItem(YaaccContentDirectory contentDirectory, String myId
101101
MimeType mimeType = MimeType.valueOf(mImageCursor.getString(mImageCursor.getColumnIndex(MediaStore.Images.ImageColumns.MIME_TYPE)));
102102
// file parameter only needed for media players which decide the
103103
// ability of playing a file by the file extension
104-
String uri = getUriString(contentDirectory, id, mimeType);
104+
String uri = getUriString(contentDirectory, id, mimeType, name, null);
105105
URI albumArtUri = URI.create("http://"
106106
+ contentDirectory.getIpAddress() + ":"
107107
+ YaaccUpnpServerService.PORT + "/thumb/" + id);

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/ImagesByBucketNameFolderBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public List<Item> browseItem(YaaccContentDirectory contentDirectory, String myId
119119
MimeType mimeType = MimeType.valueOf(mImageCursor.getString(mImageCursor.getColumnIndex(MediaStore.Images.ImageColumns.MIME_TYPE)));
120120
// file parameter only needed for media players which decide the
121121
// ability of playing a file by the file extension
122-
String uri = getUriString(contentDirectory, id, mimeType);
122+
String uri = getUriString(contentDirectory, id, mimeType, name, null);
123123
String albumArtUri = "http://" + contentDirectory.getIpAddress() + ":"
124124
+ YaaccUpnpServerService.PORT + "/thumb/" + id;
125125

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/MusicAlbumFolderBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public List<MusicTrack> browseItem(YaaccContentDirectory contentDirectory,
196196
.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
197197
// file parameter only needed for media players which decide
198198
// the ability of playing a file by the file extension
199-
String uri = getUriString(contentDirectory, id, mimeType);
199+
String uri = getUriString(contentDirectory, id, mimeType, title, null);
200200
URI albumArtUri = URI.create("http://"
201201
+ contentDirectory.getIpAddress() + ":"
202202
+ YaaccUpnpServerService.PORT + "/album/" + albumId);

yaacc/src/main/java/de/yaacc/upnp/server/contentdirectory/MusicAlbumItemBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
131131
// file parameter only needed for media players which decide
132132
// the ability of playing a file by the file extension
133133

134-
String uri = getUriString(contentDirectory, id, mimeType);
134+
String uri = getUriString(contentDirectory, id, mimeType, title, null);
135135
URI albumArtUri = URI.create("http://"
136136
+ contentDirectory.getIpAddress() + ":"
137137
+ YaaccUpnpServerService.PORT + "/album/" + albumId);

0 commit comments

Comments
 (0)