vendredi 13 février 2015

Volume change effect both AVPlayer and AudioServices

I have both AVPlayer and AudioServices to play sound in my game. I use AVPlayer for playing a background music which I do need to loop continuously, and I use AudioServices with soundID to play sound effects on button tap.


The problem is when I decrease the volume with iPhone side volume buttons it does affect on music play by AVPlayer but not on sounds which play with AudioServices.


What should I do to make them both play at the same volume and volume change affect on them both at same time?


Html5 audio playlist not working on the Safari

I wonder if any one can help me sort this problem. My audio playlist is working fine in chrome , ie , and firefox but NOT Safari browser.


I tried using it on iphone safari browser and it works but Not on full screen.


It will be great if some one can help.


Here is my code:





function loadPlayer()
{
var audioPlayer = new Audio();
audioPlayer.controls="";
audioPlayer.setAttribute("data-index", -1); //set default index to -1.
audioPlayer.addEventListener('ended',nextSong,false);
audioPlayer.addEventListener('error',errorFallback,true);
document.getElementById("player").appendChild(audioPlayer);
}


function nextSong(index, e)
{
var next;
var audioPlayer = document.getElementsByTagName('audio')[0];
//check for index. If so load from index. If not, index is defined auto iterate to next value.
if (index >= 0)
{
next = index;
}
else
{
next = parseInt(audioPlayer.getAttribute("data-index"))+1;
next >= urls.length ? next = 0 : null;
}

audioPlayer.src=urls[next][0]; //load the url.
audioPlayer.setAttribute("data-index", next);
//disable the player.
var audioPlayerControls = document.getElementById("playerControls");
audioPlayer.removeEventListener('canplay',enablePlayerControls,false);
audioPlayerControls.setAttribute("disabled", true);
audioPlayer.addEventListener('canplay',enablePlayerControls,false);
audioPlayer.load();

//show the image:
var image = document.getElementById("playerList").querySelectorAll("a")[next].querySelector("img").cloneNode();
image.style.width = "30px";
if(audioPlayerControls.querySelector("img"))
{
audioPlayerControls.replaceChild(image, audioPlayerControls.querySelector("img"));
}
else
{
audioPlayerControls.insertBefore(image, audioPlayerControls.querySelector("a"));
}

}

function enablePlayerControls()
{
//File has loaded, so we can start playing the audio.
//Enable the player options.
var audioPlayer = document.getElementsByTagName('audio')[0];
audioPlayer.removeEventListener('canplay',enablePlayerControls,false);
document.getElementById("playerControls").removeAttribute("disabled");
audioPlayer.play();
}

function errorFallback() {
nextSong();
}


function playPause()
{
var audioPlayer = document.getElementsByTagName('audio')[0];
if (audioPlayer.paused)
{
audioPlayer.play();
} else
{
audioPlayer.pause();
}
}
function pickSong(e)
{
//we want the correct target. Select it via the event (e).
var target;

//pickSong does the selecting:
if (e && e.target && e.target.tagName && e.target.tagName.toLowerCase() == "img")
{
//The event target = the img element.
target = e.target.parentElement;
}
else
{
//the event target is the a element
target = e.target;
}
var index = target.getAttribute("data-index"); //get the song index stored in the data-index attribute.
nextSong(index);
}

var urls = new Array();
urls[0] = ['http://ift.tt/1tr9ENU', 'radio/radio almazighia.png'];
urls[1] = ['http://ift.tt/1CFwPY4', "radio/alwatania.png"];
urls[2] = ['http://ift.tt/1zj92pF', "radio/inter.jpg"];
urls[3] = ['http://ift.tt/1Bp6YOu', "radio/france maghrib.jpg"];

function startAudioPlayer()
{
loadPlayer();
for (var i = 0; i < urls.length; ++i)
{
//this for loop runs through all urls and appends them to the player list. This smooths the adding off new items. You only have
//to declare them in the array, the script does the rest.
var link = document.createElement("a");
link.href = "javascript: void(0)";
link.addEventListener("click", pickSong, false);
link.setAttribute("data-index", i);
link.img = document.createElement("img");
link.img.src = urls[i][1];
link.appendChild(link.img);
document.getElementById("playerList").appendChild(link);
}
}

//Event that starts the audio player.
window.addEventListener("load", startAudioPlayer, false);



#playerControls[disabled=true] > a{
color: #eee;
}



<span id="playerControls" disabled="true">
<a href="javascript: void(0);" onclick="playPause()" id="player" title="Play">Play</a>
<a href="javascript: void(0);" onclick="playPause()" id="player" title="Stop">Stop</a>
</span>
<a href="javascript: void(0);" onclick="nextSong()" id="player" title="Next Station">Next Track</a>

<!-- player ends -->

<br>
<br>
<!-- img links start -->

<div id="playerList">

</div>



ffmpeg not creating audio file

I'm trying to write raw s16le audio to an audio file using ffmpeg. This is the command I'm using:



ffmpeg -y -f s16le -acodec pcm_s16le -ar 44100 -ac 1 -i - -vn -ar 44100 -ac 1 OUTPUT_FILE.wav


After this command is handled I use stdin to put data in the encoder like this:



fwrite(samples_, sizeof(short int*), numSamples, audioffmpeg);


where samples_ is a short int* with a number of numSamples combined. At the moment I'm trying this per sample (so numSamples is 1).


For some reason this isn't creating a new file. Although, when I use a previously created file as input (so I don't use stdin) it does create a new file.


FFmpeg doesn't seem to be outputting so I can't give that


Wowza: Vod Adaptive bit-rate Streaming issue in audio file

I am using Wowzastreamengine-4.0.3 For my application. I have build wowza on the server. I have to adaptive bit-rate for 2g (or lower network connection).


I have set up all adaptive bitrate by following this link


http://ift.tt/1FG3E5I


I have created different smile files for different bitrate, but non of them working correctly, As i have tested in 2g network through running application my android mobile. but it is not working perfectly, it stick on some point I cann't find what the problem there? please help me.thanks in advance


I mentioned below some smile file .all files in wowzastreamengine/content/folder


1



<?xml version="1.0" encoding="UTF-8"?>
<smil title="testing">
<body>
<switch>
<audio src="mp3:54b11d4790db4b9f1a0adc4a.mp3" systemLanguage="hin">
<param name="audioBitrate" value="10000" valuetype="data"></param>
</audio>
</switch>
</body>
</smil>


2



<?xml version="1.0" encoding="UTF-8"?>
<smil title="MStream">
<body>
<switch>
<audio src="54b11ce390db4b9f1a0adc47.mp3" systemLanguage="eng" audio-bitrate="48000">
<param name="audioBitrate" value="48000" valuetype="data"></param>
</audio>
</switch>
</body>
</smil>


3



<?xml version="1.0" encoding="UTF-8"?>
<smil title="Stream">
<body>
<switch>
<video height="360" src="mp3:54b11d4790db4b9f1a0adc4a.mp3"
systemLanguage="eng" width="240" audio-bitrate="36000" system-bitrate="36000"/>
</switch>
</body>
</smil>


4



<?xml version="1.0" encoding="UTF-8"?>
<smil title="testing">
<body>
<switch>
<audio src="mp3:54b11d4790db4b9f1a0adc4a.mp3" systemLanguage="hin">
<param name="audioBitrate" value="10000" valuetype="data"></param>
</audio>
</switch>
</body>
</smil>


5



<?xml version="1.0" encoding="UTF-8"?>
<smil title="videotesting">
<body>
<switch>
<video height="20" src="mp3:54b11d4790db4b9f1a0adc4a.mp3"
systemLanguage="eng" width="20" video-bitrate="10000" audio-bitrate="10000"/>
</switch>
</body>
</smil>

jeudi 12 février 2015

ffmpeg on android -- cannot write output file

I'm trying to use ffmpeg as a shared library in Android to convert PCM to an .mp4 file. Before going further, I hit a snag in my openOutputFile function, I have the following which has given me an error (passing in "/sdcard/a.mp4" for filename):



if ((error = avio_open(&output_io_context, filename,
AVIO_FLAG_WRITE)) < 0) {
__android_log_print(ANDROID_LOG_ERROR, "encoder","couldn't open output file");
exit(1);
}


My configure for ffmpeg compilation is as follows:



./configure \
--prefix=$PREFIX \
--enable-demuxer=mov \
--enable-muxer=mov \
--enable-libvpx \
--enable-libvorbis \
--enable-protocol=file \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \


when searching, I have come across others' experiencing similar issues and added the --enable-protocol=file and --enable-muxer=mov when compiling ffmpeg. I did add the permissions to external storage in the manifest.xml file. Please let me know what you think. Thanks.


How to build a functionality to download Audio files to local folder or downloads folder from a silverlight application?

I have a silverlight web application, in which I have a functionality to play an audio/sound files.Currently sound files are stored in Client Bin folder, sound files can be in any folder on server.I want to build a functionality to download these sound files to users pc. I tried using save file dialog,but couldn't download the audio files.


Mysql server has gone away while storing large (2MB) audio file in LONGBLOB

I want to store a audio file in mysql database. I am using LONGBLOB to store the base64 encoded string of this audio file. but just as i perform my query, i am getting this warning with no inserting on the database:



Warning: mysql_query() [function.mysql-query]: MySQL server has gone away


When i upload any image file, i am getting no error and the code works fine. this happens when i upload video and audio file. below in the code i am using:



<?php
include 'database_handler.php';
if(isset($_FILES['fileToUpload']['name'])){
echo "uploading. . .";
$file = rand(0, 10000000).$_FILES['fileToUpload']['name'];
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file)) {
if($fp = fopen($file,"rb", 0))
{
$picture = fread($fp,filesize($file));
fclose($fp);
$base64 = base64_encode($picture);
//echo $base64;
$db = new Database();
$db->test($base64);
}
}
}
?>
<form action="test.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>


Here is the function code that i am calling:



function test($base64String){
if (mysql_query("update users set attribute1='$base64String' where id = '83'")){
echo "success";

}else{
mysql_error();
}
}


thanks