@@ -556,8 +556,8 @@ func (a *Application) PlayableMediaType(filename string) bool {
556556}
557557
558558func (a * Application ) possibleContentType (filename string ) (string , error ) {
559- //If filename is an URL returns the content-type from the HEAD response headers
560- //Otherwise returns the content-type thanks to filetype package
559+ // If filename is an URL returns the content-type from the HEAD response headers
560+ // Otherwise returns the content-type thanks to filetype package
561561 var contentType string
562562
563563 if strings .Contains (filename , "://" ) {
@@ -584,7 +584,6 @@ func (a *Application) possibleContentType(filename string) (string, error) {
584584 filename = parts [0 ]
585585 }
586586
587- // https://developers.google.com/cast/docs/media
588587 switch ext := strings .ToLower (path .Ext (filename )); ext {
589588 case ".jpg" , ".jpeg" :
590589 return "image/jpeg" , nil
@@ -622,6 +621,20 @@ func (a *Application) knownFileType(filename string) bool {
622621 return false
623622}
624623
624+ func (a * Application ) castPlayableContentType (contentType string ) bool {
625+ // https://developers.google.com/cast/docs/media
626+ switch contentType {
627+ case "image/apng" , "image/bmp" , "image/gif" , "image/jpeg" , "image/png" , "image/webp" :
628+ return true
629+ case "audio/mp2t" , "audio/mp3" , "audio/mp4" , "audio/ogg" , "audio/wav" , "audio/webm" :
630+ return true
631+ case "video/mp4" , "video/webm" :
632+ return true
633+ }
634+
635+ return false
636+ }
637+
625638func (a * Application ) PlayedItems () map [string ]PlayedItem {
626639 return a .playedItems
627640}
@@ -854,7 +867,9 @@ func (a *Application) loadAndServeFiles(filenames []string, contentType string,
854867 // If this is a media file we know the chromecast can play,
855868 // then we don't need to transcode it.
856869 contentTypeToUse , _ = a .possibleContentType (filename )
857- transcodeFile = false
870+ if a .castPlayableContentType (contentTypeToUse ) {
871+ transcodeFile = false
872+ }
858873 } else if transcodeFile {
859874 contentTypeToUse = "video/mp4"
860875 }
0 commit comments