簡體   English   中英

Google Cast:加載元數據錯誤並且不存在Access-Control-Allow-Origin標頭

[英]Google Cast: Load Metadata Error and No Access-Control-Allow-Origin header is present

我嘗試使用我的Android應用程序投射視頻流。 流來自我自己的網絡中的衛星接收器。 我通過http鏈接訪問流,例如:

http://192.168.188.23:8001/1:0:19:283D:3FB:1:C00000:0

當我在VLC中打開流時,我得到以下編解碼器信息:

類型:視頻/編解碼器:H264-MPEG-4 AVC(第10部分)(h264)

在我的應用中,我構建了此MediInfo:

private static MediaInfo buildMediaInfo(String title, String subTitle, String studio, String url, String imgUrl, String bigImageUrl, List<MediaTrack> tracks) {
    MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
    movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subTitle);
    movieMetadata.putString(MediaMetadata.KEY_TITLE, title);
    movieMetadata.putString(MediaMetadata.KEY_STUDIO, studio);
    return new MediaInfo.Builder(url)
            .setStreamType(MediaInfo.STREAM_TYPE_LIVE)
            .setContentType("video/mp4")
            .setMetadata(movieMetadata)
            .setMediaTracks(tracks)
            .build();
}

來自我的Chromecast的錯誤日志:

Failed to load resource: the server responded with a status of 404 (Not Found) https://www.gstatic.com/eureka/player/undefined  
[0.292s] [goog.net.WebSocket] Opening the WebSocket on ws://localhost:8008/v2/ipc cast_receiver.js:18
The page at 'https://www.gstatic.com/eureka/player/player.html?skin' was loaded over HTTPS, but ran insecure content from 'ws://localhost:8008/v2/ipc': this content should also be loaded over HTTPS. player.html:1 
Connecting to a non-secure WebSocket server from a secure origin is deprecated. player.html:1  
[0.428s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/v2/ipc cast_receiver.js:18
Failed to load resource: the server responded with a status of 404 (Not Found) https://www.gstatic.com/eureka/player/undefined
The page at 'https://www.gstatic.com/eureka/player/player.html?skin' was loaded over HTTPS, but displayed insecure content from 'http://192.168.188.23:8001/1:0:19:283D:3FB:1:C00000:0:0:0:': this content should also be loaded over HTTPS.  media_player.js:38 
XMLHttpRequest cannot load http://192.168.188.23:8001/1:0:19:283D:3FB:1:C00000:0:0:0:. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.gstatic.com' is therefore not allowed access. player.html:1  
[ 13.011s] [cast.receiver.MediaManager] Load metadata error cast_receiver.js:18
nb cast_receiver.js:18
kb.Yb cast_receiver.js:18
B.log cast_receiver.js:13
I cast_receiver.js:16
Z.ra cast_receiver.js:88
g.ra cast_receiver.js:53
Ib cast_receiver.js:23
Fb cast_receiver.js:24
(anonymous function) cast_receiver.js:21
e.onError player.js:53
K media_player.js:61
Ie.Ba media_player.js:117
R.yb media_player.js:67
pc media_player.js:34
h.dispatchEvent media_player.js:33
Hc media_player.js:39
Jc media_player.js:42
D.dh media_player.js:40
D.tf media_player.js:40

我無法在信息流本身上更改某些內容。

這是我的代碼中的問題還是來自Sat-Receiver(流)的問題?當它來自我的Sat-Receiver時是否有解決方案?

編輯:

解決CORS問題后的新錯誤日志:

Failed to load resource: the server responded with a status of 404 (Not Found) https://www.gstatic.com/eureka/player/undefined
 [  0.280s] [goog.net.WebSocket] Opening the WebSocket on ws://localhost:8008/v2/ipc cast_receiver.js:18
The page at 'https://www.gstatic.com/eureka/player/player.html?skin' was loaded over HTTPS, but ran insecure content from 'ws://localhost:8008/v2/ipc': this content should also be loaded over HTTPS.
 player.html:1
Connecting to a non-secure WebSocket server from a secure origin is deprecated. player.html:1
 [  0.367s] [goog.net.WebSocket] WebSocket opened on ws://localhost:8008/v2/ipc cast_receiver.js:18
Failed to load resource: the server responded with a status of 404 (Not Found) https://www.gstatic.com/eureka/player/undefined
The page at 'https://www.gstatic.com/eureka/player/player.html?skin' was loaded over HTTPS, but displayed insecure content from 'http://192.168.188.32/teststream1.php': this content should also be loaded over HTTPS.
 cast_receiver.js:55
 [ 12.071s] [cast.receiver.MediaManager] Load metadata error cast_receiver.js:18
 nb cast_receiver.js:18
 kb.Yb cast_receiver.js:18
 B.log cast_receiver.js:13
 I cast_receiver.js:16
 Z.ra cast_receiver.js:88
 g.ra cast_receiver.js:53
 Ib cast_receiver.js:23
 Fb cast_receiver.js:24
 (anonymous function) cast_receiver.js:21

編輯2:來自流的標頭看起來像這樣(用php捕獲):

[0] => HTTP/1.0 200 OK
[1] => Date: Sat, 04 Oct 2014 18:38:23 GMT
[2] => Server: Apache/2.2.22 (Debian)
[3] => X-Powered-By: PHP/5.4.4-14+deb7u9
[4] => Connection: Close
[5] => Access-Control-Allow-Origin: *
[6] => Content-Type: video/mpeg

當我在VLC中打開流時,我得到以下編解碼器信息:

類型:視頻/編解碼器:H264-MPEG-4 AVC(第10部分)(h264)

Android代碼與上述相同。

接收者: https : //github.com/googlecast/Cast-Simple-Receiver/blob/master/receiver.html

編輯3

使用自定義樣式的適配器和優化的代碼:

錯誤日志投射:

cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);
undefined
 [405.177s] [cast.receiver.IpcChannel] Received message: {"data":"{\"currentTime\":0,\"type\":\"LOAD\",\"media\":{\"streamType\":\"BUFFERED\",\"duration\":0,\"contentType\":\"video\\/mpeg\",\"contentId\":\"http:\\/\\/192.168.188.32\\/teststream1.php\",\"metadata\":{\"subtitle\":\"Auslandskorrespondenten berichten\",\"studio\":\"Das Erste HD\",\"title\":\"Weltspiegel\",\"metadataType\":1}},\"requestId\":2,\"autoplay\":true}","namespace":"urn:x-cast:com.google.cast.media","senderId":"229:de.resper.e2cast-22"} cast_receiver.js:18
 [405.187s] [cast.receiver.CastMessageBus] Dispatching CastMessageBus message cast_receiver.js:18
 [405.193s] [cast.receiver.MediaManager] MediaManager message received cast_receiver.js:18
 [405.198s] [cast.receiver.MediaManager] Dispatching MediaManager load event cast_receiver.js:18
 [406.017s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.system","senderId":"SystemSender","data":"{\"type\":\"setappstate\",\"statusText\":\"Now Casting: Weltspiegel\"}"} cast_receiver.js:18
 [406.046s] [cast.receiver.MediaManager] Load - contentId: http://192.168.188.32/teststream1.php autoplay: true time: 0 cast_receiver.js:18
The page at 'https://www.gstatic.com/eureka/player/player.html?skin' was loaded over HTTPS, but displayed insecure content from 'http://192.168.188.32/teststream1.php': this content should also be loaded over HTTPS.
 cast_receiver.js:55
 [408.624s] [cast.receiver.MediaManager] Load metadata error cast_receiver.js:18nb cast_receiver.js:18kb.Yb cast_receiver.js:18B.log cast_receiver.js:13I cast_receiver.js:16Z.ra cast_receiver.js:88g.ra cast_receiver.js:53Ib cast_receiver.js:23Fb cast_receiver.js:24(anonymous function) cast_receiver.js:21
 [409.519s] [cast.receiver.MediaManager] Sending error message to 229:de.resper.e2cast-22 cast_receiver.js:18
 [409.523s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.media","senderId":"229:de.resper.e2cast-22","data":"{\"requestId\":2,\"type\":\"LOAD_FAILED\"}"} cast_receiver.js:18
 [410.301s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.system","senderId":"SystemSender","data":"{\"type\":\"setappstate\",\"statusText\":\"Ready To Cast\"}"} cast_receiver.js:18

我在您的帖子中沒有看到任何問題,因此不確定您要問的是什么。 您提到的錯誤表明您遇到了chromecast所需的CORS問題(基於W3C要求),而Cast SDK方面您無能為力。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM