Skip to content

Commit

Permalink
Add declaration of android supported audio formats
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Jan 2, 2024
1 parent 8fb5b0f commit 404d1de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -44,9 +44,10 @@ class ApplicationController < ActionController::Base
def need_transcode?(song)
song_format = song.format

return true unless song_format.in?(Stream::SUPPORTED_FORMATS)
return true unless song_format.in?(Stream::WEB_SUPPORTED_FORMATS)
return true if browser.safari? && !song_format.in?(Stream::SAFARI_SUPPORTED_FORMATS)
return true if ios_app? && !song_format.in?(Stream::IOS_SUPPORTED_FORMATS)
return true if android_app? && !song_format.in?(Stream::ANDROID_SUPPORTED_FORMATS)

Setting.allow_transcode_lossless? ? song.lossless? : false
end
Expand Down
5 changes: 3 additions & 2 deletions app/models/stream.rb
Expand Up @@ -3,9 +3,10 @@
class Stream
extend Forwardable

SUPPORTED_FORMATS = MediaFile::SUPPORTED_FORMATS - %w[wma]
WEB_SUPPORTED_FORMATS = MediaFile::SUPPORTED_FORMATS - %w[wma]
SAFARI_SUPPORTED_FORMATS = MediaFile::SUPPORTED_FORMATS - %w[ogg opus oga]
IOS_SUPPORTED_FORMATS = MediaFile::SUPPORTED_FORMATS - %w[ogg opus oga]
IOS_SUPPORTED_FORMATS = SAFARI_SUPPORTED_FORMATS
ANDROID_SUPPORTED_FORMATS = WEB_SUPPORTED_FORMATS

TRANSCODE_FORMAT = "mp3"
TRANSCODE_CACHE_DIRECTORY = Rails.root.join("tmp/cache/media_file")
Expand Down

0 comments on commit 404d1de

Please sign in to comment.