mirror of
https://github.com/fly-apps/live_beats.git
synced 2025-01-20 20:08:07 +00:00
WIP
This commit is contained in:
parent
a1c6c454f0
commit
6c13ad3b9b
6 changed files with 16 additions and 15 deletions
|
@ -218,7 +218,7 @@ defmodule LiveBeats.MediaLibrary do
|
||||||
segment
|
segment
|
||||||
end)
|
end)
|
||||||
|
|
||||||
insert_text_segments(song, segments)
|
insert_speech_segments(song, segments)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{ref, song}
|
{ref, song}
|
||||||
|
@ -240,8 +240,8 @@ defmodule LiveBeats.MediaLibrary do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp insert_text_segments(song, segments) do
|
defp insert_speech_segments(song, segments) do
|
||||||
Repo.update_all(from(s in Song, where: s.id == ^song.id), set: [text_segments: segments])
|
Repo.update_all(from(s in Song, where: s.id == ^song.id), set: [speech_segments: segments])
|
||||||
end
|
end
|
||||||
|
|
||||||
defp broadcast_imported(%Accounts.User{} = user, songs) do
|
defp broadcast_imported(%Accounts.User{} = user, songs) do
|
||||||
|
|
|
@ -24,7 +24,7 @@ defmodule LiveBeats.MediaLibrary.Song do
|
||||||
field :position, :integer, default: 0
|
field :position, :integer, default: 0
|
||||||
belongs_to :user, Accounts.User
|
belongs_to :user, Accounts.User
|
||||||
belongs_to :genre, LiveBeats.MediaLibrary.Genre
|
belongs_to :genre, LiveBeats.MediaLibrary.Genre
|
||||||
embeds_many :text_segments, LiveBeats.MediaLibrary.TextSegment
|
embeds_many :speech_segments, LiveBeats.MediaLibrary.TextSegment
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,7 +164,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
end
|
end
|
||||||
|
|
||||||
active_song = MediaLibrary.get_current_active_song(profile)
|
active_song = MediaLibrary.get_current_active_song(profile)
|
||||||
speech_segments = if active_song, do: active_song.text_segments, else: []
|
speech_segments = if active_song, do: active_song.speech_segments, else: []
|
||||||
|
|
||||||
songs = MediaLibrary.list_profile_songs(profile, 50)
|
songs = MediaLibrary.list_profile_songs(profile, 50)
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
stream_insert(socket, :songs, %MediaLibrary.Song{song | status: :playing})
|
stream_insert(socket, :songs, %MediaLibrary.Song{song | status: :playing})
|
||||||
|
|
||||||
active_song_id ->
|
active_song_id ->
|
||||||
Enum.reduce(song.text_segments, socket, fn seg, acc ->
|
Enum.reduce(song.speech_segments, socket, fn seg, acc ->
|
||||||
stream_insert(acc, :speech_segments, seg)
|
stream_insert(acc, :speech_segments, seg)
|
||||||
end)
|
end)
|
||||||
|> stop_song(active_song_id)
|
|> stop_song(active_song_id)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<p class="inline text-gray-500 text-sm">(songs expire every six hours)</p>
|
<p class="inline text-gray-500 text-sm">(songs expire every six hours)</p>
|
||||||
|
|
||||||
<.form
|
<.form
|
||||||
|
for={%{}}
|
||||||
as={:songs}
|
as={:songs}
|
||||||
id="song-form"
|
id="song-form"
|
||||||
class="space-y-8"
|
class="space-y-8"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
defmodule LiveBeats.Repo.Migrations.AddSpeechSegmentsToSongs do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:songs) do
|
||||||
|
add :speech_segments, {:array, :map}, null: false, default: []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +0,0 @@
|
||||||
defmodule LiveBeats.Repo.Migrations.AddLyricsToSongs do
|
|
||||||
use Ecto.Migration
|
|
||||||
|
|
||||||
def change do
|
|
||||||
alter table(:songs) do
|
|
||||||
add :text_segments, {:array, :map}, null: false, default: []
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue