Skip to content

Commit

Permalink
Fix #40, fix #38, fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-W committed Dec 25, 2020
1 parent e876183 commit 471fe76
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<activity
android:name=".ui.dashboard.DashboardActivity"
android:label="IPv8 Apps"
android:label="Trustchain Superapp"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PlaylistsOverviewFragment : MusicBaseFragment(R.layout.fragment_release_ov
private var lastReleaseBlocksSize = -1
private var lastSwarmHealthMapSize = -1
private var searchQuery = ""
private val maxPlaylists = 30 // Max playlists to show
private val maxPlaylists = 100 // Max playlists to show

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down Expand Up @@ -133,9 +133,10 @@ class PlaylistsOverviewFragment : MusicBaseFragment(R.layout.fragment_release_ov
val magnet = block.transaction["magnet"]
val title = block.transaction["title"]
val torrentInfoName = block.transaction["torrentInfoName"]
// val publisher = block.transaction["publisher"]
val publisher = block.transaction["publisher"]
if (magnet is String && magnet.length > 0 && title is String && title.length > 0 &&
torrentInfoName is String && torrentInfoName.length > 0
torrentInfoName is String && torrentInfoName.length > 0 && publisher is String &&
publisher.length > 0
) {
val coverArt = Util.findCoverArt(
File(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.example.musicdao.MusicService
import com.example.musicdao.R
import com.example.musicdao.dialog.TipArtistDialog
import com.example.musicdao.net.ContentSeeder
import com.example.musicdao.net.TorrentConfig
import com.example.musicdao.player.AudioPlayer
import com.example.musicdao.util.Util
import com.example.musicdao.wallet.CryptoCurrencyConfig
Expand Down Expand Up @@ -136,7 +137,7 @@ class ReleaseFragment(
}
return
}
sessionManager.download(torrentInfo, saveDir)
sessionManager.download(torrentInfo, saveDir, null, null, TorrentConfig.bootstrapPeers)
} else {
// The torrent has not been finished yet previously, so start downloading
val torrentInfo = fetchTorrentInfo(saveDir)
Expand All @@ -145,11 +146,11 @@ class ReleaseFragment(
} else {
currentTorrent = torrentInfo
}
sessionManager.download(torrentInfo, saveDir)
sessionManager.download(torrentInfo, saveDir, null, null, TorrentConfig.bootstrapPeers)
}
val torrent = sessionManager.find(currentTorrent?.infoHash())
// val sessionHandle = SessionHandle(sessionManager.swig())
// sessionHandle.addDhtNode(Pair("130.161.119.207", 51413))
val sessionHandle = SessionHandle(sessionManager.swig())
sessionHandle.addDhtNode(Pair("130.161.119.207", 51413))

// Prioritize file 1
activity?.runOnUiThread {
Expand Down Expand Up @@ -321,6 +322,7 @@ class ReleaseFragment(
* Update the UI with the latest state of the selected TorrentHandle
*/
fun onStreamProgress(torrentHandle: TorrentHandle) {
val saveDir = context?.cacheDir ?: return
val fileIndex = currentFileIndex
val currentProgress = torrentHandle.fileProgress()
if (currentProgress != null) updateFileProgress(currentProgress)
Expand All @@ -330,10 +332,10 @@ class ReleaseFragment(
val currentFileProgress =
currentProgress[currentFileIndex]
val audioPlayer = AudioPlayer.getInstance()
val audioFile = File(torrentHandle.torrentFile().files().filePath(currentFileIndex))
val audioFile = File(torrentHandle.torrentFile().files().filePath(currentFileIndex, saveDir.absolutePath))
if (!audioFile.isFile) return
// If we selected a file to play but it is not playing, start playing it after 30% progress
if (currentFileProgress > 64 * 1024 && audioPlayer != null && !audioPlayer.isPlaying() &&
if (currentFileProgress > 500 * 1024 && audioPlayer != null && !audioPlayer.isPlaying() &&
currentFileIndex != -1
) {
startPlaying(
Expand Down
1 change: 1 addition & 0 deletions musicdao/src/main/java/com/example/musicdao/util/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ object Util {
if (fileNameLocal.endsWith(s)) {
fileNameLocal = fileNameLocal.substringBefore(s)
fileNameLocal = fileNameLocal.replace("_", " ")
fileNameLocal = fileNameLocal.substringAfterLast("-")
return fileNameLocal
}
}
Expand Down

0 comments on commit 471fe76

Please sign in to comment.