简体   繁体   English

Google Cast:加载元数据错误并且不存在Access-Control-Allow-Origin标头

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

I try to cast a stream with my Android app. 我尝试使用我的Android应用程序投射视频流。 The stream comes from a Sat-Receiver in my own network. 流来自我自己的网络中的卫星接收器。 I access the stream over a http Link like: 我通过http链接访问流,例如:

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

When I open the stream in VLC i get this codec information: 当我在VLC中打开流时,我得到以下编解码器信息:

Type: Video / Codec: H264 - MPEG-4 AVC (part10) (h264) 类型:视频/编解码器:H264-MPEG-4 AVC(第10部分)(h264)

In my app, I build this MediInfo: 在我的应用中,我构建了此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();
}

The error Log from my Chromecast: 来自我的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

I am not able to change something at the stream itself. 我无法在信息流本身上更改某些内容。

Is that a problem in my code or a problem from my Sat-Receiver (the stream) & is there a solution when it is a problem from my Sat-Receiver? 这是我的代码中的问题还是来自Sat-Receiver(流)的问题?当它来自我的Sat-Receiver时是否有解决方案?

EDIT: 编辑:

after solve the CORS Problem new ERROR Log: 解决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

EDIT 2: The header from the stream look like this (capture with php): 编辑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

When I open the stream in VLC i get this codec information: 当我在VLC中打开流时,我得到以下编解码器信息:

Type: Video / Codec: H264 - MPEG-4 AVC (part10) (h264) 类型:视频/编解码器:H264-MPEG-4 AVC(第10部分)(h264)

Android code same as above. Android代码与上述相同。

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

EDIT 3 编辑3

With Custom Styled Adapter and optimzed Code: 使用自定义样式的适配器和优化的代码:

Error Log Cast: 错误日志投射:

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

I don't see a question in your post, so I am not sure what exactly you are asking; 我在您的帖子中没有看到任何问题,因此不确定您要问的是什么。 the error that you mention states that you are running into CORS issue which is required by chromecast (based on W3C requirements) and there is nothing you can do from the Cast SDK side to get around that. 您提到的错误表明您遇到了chromecast所需的CORS问题(基于W3C要求),而Cast SDK方面您无能为力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ionic:请求的资源上不存在“ Access-Control-Allow-Origin”标头 - ionic: No 'Access-Control-Allow-Origin' header is present on the requested resource WebView不存在“ Access-Control-Allow-Origin”标头[ANDROID] - WebView No 'Access-Control-Allow-Origin' header is present [ANDROID] 模型查看器颤动请求的资源上不存在“Access-Control-Allow-Origin”标头 - modelviewer flutter No 'Access-Control-Allow-Origin' header is present on the requested resource Android WebView“请求的资源上不存在&#39;Access-Control-Allow-Origin&#39;标头” - Android WebView “No 'Access-Control-Allow-Origin' header is present on the requested resource” Heroku上的Meteor移动服务器-不存在Access-Control-Allow-Origin标头 - Meteor Mobile Server on Heroku - No Access-Control-Allow-Origin header is present JSON_2_Region.json。 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 因此,不允许访问原始“空”。 - JSON_2_Region.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. Android 4.1上的Access-Control-Allow-Origin错误 - Access-Control-Allow-Origin Error At Android 4.1 科尔多瓦没有访问控制允许来源 - cordova No Access-Control-Allow-Origin 如何解决“ CORS策略:“ Access-Control-Allow-Origin”标头的值不等于提供的来源。” - How to solve "CORS policy: The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin.'? android webview - 访问控制允许来源 - android webview - Access-Control-Allow-Origin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM