HTML5 Audio won't trigger / work in Safari - html5-audio

the following code works as intended on all browsers except Safari (using version 5.1.7 for windows 7).
var texto01 = document.getElementById("texto01");
texto01.onkeyup = function(tecla){
if(tecla.keyCode == 13){ //If Enter is keyup
if((valorAnt[0] != texto01.value) && (texto01.value != "")){ //Check to see if answer has changed and field is not empty
valorAnt[0] = texto01.value; //Since value has change, set it to be new previous answer
if(texto01.value == "5747"){ //Correct answer user has to type
ctx.clearRect(739, 57, 35, 35);
ctx.drawImage(bienImg, 739, 57); //Tick image
var cBien = Math.ceil(Math.random()*2); //There are two audio files that can be played if answer is correct
var cSonidoB = "bien" + cBien;
document.getElementById(cSonidoB).play(); //play the "random" audio for right answer
}
else{ //Answer is wrong
ctx.clearRect(739, 57, 35, 35);
ctx.drawImage(malImg, 739, 57); //X mark image
var cMal = Math.ceil(Math.random()*3); //There are three audio files that can be played if answer is wrong
var cSonidoM = "mal" + cMal;
document.getElementById(cSonidoM).play(); //play the "random" audio for wrong answer
}
}
}
}//texto01
All audio tags are declared like this:
<audio id = "mal1" preload = "auto">
<source src="Sounds/mal01.ogg" type="audio/ogg"></source>
<source src="Sounds/mal01.mp3" type="audio/mpeg"></source>
</audio>
I have tried the following with no success:
1) Put the MP3 source before the OGG.
2) Changed the type to "audio/mp3"
3) Remove the "random" part of choosing which audio to play and straight up assign an audio ID to play.

maybe you have to add some code in .htaccess like the following:
AddType audio/mpeg mp3
AddType audio/mp4 m4a
AddType audio/ogg ogg
AddType audio/ogg oga
AddType audio/webm webma
AddType audio/wav wav
AddType video/mp4 mp4
AddType video/mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
AddType video/webm webmv
AddType audio/mpeg .mp3
AddType audio/mp4 .m4a
AddType audio/ogg .ogg
AddType audio/ogg .oga
AddType audio/webm .webma
AddType audio/wav .wav
AddType video/mp4 .mp4
AddType video/mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm
AddType video/webm .webmv

Related

Google Chrome MIME type for .csv file?

Does Google chrome support csv MIME type? I have the following entries in my mime.types (Nginx) file (these are only csv related entries):
types {
text/csv csv;
text/comma-separated-values csv;
text/anytext csv;
application/csv csv;
application/csv+xml csv;
}
Here is my nginx.conf file:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile off;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
But Chrome won't like it! No problem on Safari though!
Is there a Chrome specific csv support?
Thanks
I resolved the issue by adding:
add_header Content-Type text/csv;
to the nginx webapp.conf file where I define my specific location:
location /ingressfile {
access_log /var/log/nginx/ingressfile.log main;
set $module company.api;
set $app app;
uwsgi_pass restapi;
uwsgi_intercept_errors on;
# add support for csv files
add_header Content-Type text/csv;
# Use this I'm-a-teapot code to redirect to static file
error_page 418 = #ingressfile;
}
Hopefully this helps people with the same kind of issues!

embed live RTMP stream in html with flowplayer(nginx-rtmp-module)

I have an nginx server with the rtmp-module. I am using ffmpeg to transcode from rtsp to rtmp. I'm able to view the live stream with VLC but I am unable to embed the video in html. Here is my nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
# HTTP server
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
# path to HLS application service
location /media_server {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /usr/local/nginx-streaming/html;
add_header Cache-Control no-cache;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
# RTMP media server
rtmp {
server {
listen 1935;
chunk_size 4000;
# Transcoding (ffmpeg needed)
application media_server {
live on;
hls on;
hls_path /usr/local/nginx-streaming/html/media_server;
hls_nested on;
hls_variant _low BANDWIDTH=640000;
hls_variant _hi BANDWIDTH=2140000;
# ffmpeg static execution
exec_static /usr/bin/ffmpeg -rtsp_transport tcp -i rtsp://myipaddress:554 -framerate 6 -video_size 1280x720 -vcodec libx264 -preset veryfast -maxrate 6144k -bufsize 3968k -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -ar 44100 -f flv rtmp://localhost/media_server/test;
}
}
}
here is my html:
<!DOCTYPE html>
<html><head>
<title></title>
<meta charset="utf-8">
<!-- for video tag based installs flowplayer depends on jQuery 1.7.2+ -->
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<!--
include flowplayer JavaScript file that does
Flash embedding and provides the Flowplayer API.
-->
<script type="text/javascript" src="http://releases.flowplayer.org/js/flowplayer-3.2.13.min.js"></script>
</head>
<body>
<!-- widescreen container, 1280x720 (clip dimensions) * 1.15, center splash -->
<div id="theplayer" style="width:512px;height:288px;margin:0 auto;text-align:center"><object id="theplayer_api" name="theplayer_api" data="http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf" type="application/x-shockwave-flash" width="100%" height="100%"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="quality" value="high"><param name="bgcolor" value="#000000"><param name="flashvars" value="config={"clip":{"url":"test","live":true,"scaling":"fit","provider":"rtmp"},"plugins":{"rtmp":{"url":"http://releases.flowplayer.org/swf/flowplayer.rtmp-3.2.13.swf","netConnectionUrl":"rtmp://localhost:1935/media_server/telesanremo"},"controls":{"url":"http://releases.flowplayer.org/swf/flowplayer.controls-3.2.16.swf"}},"playerId":"theplayer","playlist":[{"url":"test","live":true,"scaling":"fit","provider":"rtmp"}]}"></object></div>
<script type="text/javascript">
$f("theplayer", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf", {
clip: {
url: 'test',
live: 'true',
provider: 'rtmp'
},
plugins: {
rtmp: {
url: 'flowplayer.rtmp-3.2.13.swf',
netConnectionUrl: 'rtmp://localhost:1935/media_server'
}
}
});
</script>
</body></html>
the error i get is:
201: unable to load stream or clip file connection failed
What am i doing wrong?

nginx HLS stream not working

I've installed nginx with RTMP module on my linux server where I want it to receive a RTMP stream from Open Broadcaster Software, convert it to HLS and play it on my private website with some HTML5 player. Receiving the stream trough RTMP works, but the HLS stream doesn't seem to work. My current config is like so:
worker_processes 1;
events {
worker_connections 1024;
}
http {
#include mime.types;
#default_type application/octet-stream;
sendfile off;
#keepalive_timeout 65;
server {
listen 8080;
#server_name localhost;
#location / {
# root html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
#*********************************************************************************************************************************
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
}
root /mnt/;
add_header Cache-Control no-cache;
# To avoid issues with cross-domain HTTP requests (e.g. during development)
#add_header Access-Control-Allow-Origin *;
}
#*********************************************************************************************************************************
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application stream {
live on;
#record off;
hls on;
hls_path /mnt/hls;
#hls_fragment 6s;
}
}
}
To recieve the RTMP stream I use rtmp://ip/stream/streamname which works fine, for receiving HLS I try to use http://ip:8080/hls/streamname.m3u8 which gives me the .m3u8 file if I type it in a browser, but doesn't seem to work on the webpage when I try to play the file in a HTML5 player. I'm testing via these pages: https://videojs.github.io/videojs-contrib-hls/ and https://demo.theoplayer.com/test-hls-mpeg-dash-stream
Can anyone help me understand what I'm doing wrong?
It would help if you shared what type of console or network errors you get when testing your HLS stream on those pages.
It might provide some insight for you to troubleshoot. For example, you might be getting Access Control Allow Origin errors by accessing your stream from a different domain. Try uncommenting this line in your nginx.conf and reloading.
#add_header Access-Control-Allow-Origin *;
I also have a reference to "video/mp2t ts;" in my hls location block.
location /hls/ {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*';
}
Cheers.
Ian
Under the line: #hls_fragment 6s;
Add the code: deny_play_all;
Apparently you can't play the hls or dash files if the rtmp stream can be played. I don't know why. It just worked for me.
nginx-1.21.1
location /hls/ {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
**root /tmp;** -> **alias /tmp;**
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*';
}

Enabling content-type application/json for all the json files in nginx

Currently I am facing some issue regarding enabling content-type in NGINX.
You can see below in nginx.conf that the default content-type is application/octet-stream.
I have 5 virtual host configured in NGINX and I want to serve all the json files with Content-Type application/json.
I have added "application/json json;" in mime.type file and restarted the nginx service but still when I access any json file it is coming by content-type application/octet-stream.
Is there anything else I need to do to serve the JSON file as application/json?
### curl -v http://www.ajay.com/abc/def/ghi/jkl/mno.json
* Hostname was NOT found in DNS cache
* Trying xx.xx.xx.xx...
* Connected to www.ajay.com (xx.xx.xx.xx) port 80 (#0)
> GET abc/def/ghi/jkl/mno.json HTTP/1.1
> User-Agent: curl/7.36.0
> Host: www.ajay.com
> Accept: */*
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: max-age=86400
< **Content-Type: application/octet-stream**
< Date: Tue, 29 Jul 2014 17:03:53 GMT
< ETag: "ab9b7b2c58d3a481e172aea95b1e87a0"
< Expires: Wed, 30 Jul 2014 17:03:53 GMT
< Last-Modified: Fri, 25 Jul 2014 13:18:14 GMT
* Server nginx is not blacklisted
< Server: nginx
< Content-Length: 603
< Connection: keep-alive
.
.
.
[root#ajay nginx]# nginx -v
nginx version: nginx/1.4.3
[root#ajay nginx]# ls -lh mime.types
-rw-r--r-- 1 root root 3.5K Jul 29 10:36 mime.types
My mime.types file
[root#ajay nginx]# cat mime.types
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
**application/json json;**
application/x-javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
My nginx.conf file
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
worker_rlimit_nofile 30000;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format combined_time '$remote_addr - $remote_user [$time_local]'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
access_log /var/log/nginx/access.log combined_time;
## Size Limits
client_body_buffer_size 16k;
client_header_buffer_size 1k;
client_max_body_size 20k;
large_client_header_buffers 4 4k;
## Timeouts
client_body_timeout 5;
client_header_timeout 5;
keepalive_timeout 5 5;
send_timeout 5;
## General Options
ignore_invalid_headers on;
keepalive_requests 2;
recursive_error_pages on;
server_tokens off;
server_name_in_redirect off;
sendfile on;
## TCP options
tcp_nopush on;
tcp_nodelay on;
## Compression
gzip on;
gzip_static on;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types text/plain application/xml application/x-javascript text/xml text/css image/x-icon image/gif image/jpeg;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
include /etc/nginx/conf.d/*.conf;
}
Please help me with this
OK, I fix this problem .
Should modify ./conf/mime.types.default add
application/json json;
./sbin/nginx -s reload
If your json file has no extension, in test phrase you can modify the nginx.conf to something like this:
http {
...
default_type application/json;
...
}
Then the files without extension are served with Content-Type: application/json.

LitJson through exception on centos using mono

I compiled mono source code(using ./configure, make, make install) for centos and seems it's ok.
mono --version
Mono JIT compiler version 2.10.9 (tarball 2013年 01月 02日 星期三 13:43:05 CST)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
But when I try to run a .ashx file which invoke LitJson, I got
<p><strong>Description: </strong>HTTP 500. Error processing request.</p>
<p><strong>Stack Trace: </strong></p><table summary="Stack Trace" class="sampleCode">
<tr><td><pre>System.MissingMethodException: Method not found: 'System.Reflection.MethodInfo.op_Inequality'.
at LitJson.JsonMapper.ToObject (System.Type type, System.String json) [0x00000] in <filename unknown>:0
at MobiusServer.Login..ctor (System.String jsondata) [0x00000] in <filename unknown>:0
at MobiusServer.MobiusHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0 </pre></td></tr>
</table>
<hr style="color: silver"/><strong>Version information: </strong> Mono Runtime Version: <tt>2.10.9 (tarball 2013/01/02 Wed 13:43:05 CST)</tt>; ASP.NET Version: <tt>2.0.50727.1433</tt></body></html>
<!--
[System.MissingMethodException]: Method not found: 'System.Reflection.MethodInfo.op_Inequality'.
at LitJson.JsonMapper.ToObject (System.Type type, System.String json) [0x00000] in <filename unknown>:0
at MobiusServer.Login..ctor (System.String jsondata) [0x00000] in <filename unknown>:0
at MobiusServer.MobiusHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0
-->
I can run the same program on my mac os x which also installed mono 2.10.9 runtime.
Did I do something wrong or miss something?
Thanks!!
After a whole day research, It turns out that mod_mono will use .NET 2.0(mod-mono-server) compile my program but my program needs .NET 4.0
After altered mod_mono.conf file below, problem resolved!
# mod_mono.conf
# Achtung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.
<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/httpd/modules/mod_mono.so
</IfModule>
<IfModule mod_headers.c>
Header set X-Powered-By "Mono"
</IfModule>
MonoAutoApplication enabled
MonoDebug true
MonoServerPath "/etc/mono/bin/mod-mono-server4"
MonoUnixSocket "/tmp/.mod_mono"
AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx