// Standard HTML5 implementation of StartMusic.
function Html5StartMusic(music)
{
var player = document.getElementById('musicPlayer');
player.volume = 0.1;
player.setAttribute('src', 'music/' + music + '.ogg');
player.play();
}
Setting volume does work in PC Chrome, but not in Android 2.3 Webkit. Is there an alternative way to make it work?
Regards,
Finally, I've workarounded the problem, writing my own player at the application side, that supports volume control. To callback player functions I use onJsAlert() as API (onConsoleMessage() seems to be better, but I heard on some phones it's disabled).
Try:
yourAudioElement.mute = true
Related
I'm very new to Webrtc. I'm trying to have a video-only as the viewer. Master is sending video and audio. When running the app on a Samsung phone, I can see that there is a call (when I turn up/down the volume, I can see it as the call's volume). It is possible to have only the video running? Please let me know what code I could share. Thank you.
I was able to resolve this issue. Again, since this is my first time working with Webrtc, I'm using AWS Webrtc Android demo. When creating the sdp offer, make sure you have OfferToReceiveAudio to false:
private fun createSdpOffer() {
val sdpMediaConstraints = MediaConstraints()
sdpMediaConstraints.mandatory.add(
MediaConstraints.KeyValuePair(
"OfferToReceiveVideo",
"true"
)
)
sdpMediaConstraints.mandatory.add(
MediaConstraints.KeyValuePair(
"OfferToReceiveAudio",
"false"
)
)
...
}
My app is music player and some of the mp3's have lower volume. I want to Boost audio volume more than 100% in react native.
I have to tried this plugin:
react-native-volume-control
react-native-system-setting
react-native-audio-manager
react-native-sound
No, It's not possible, You have to increase the volume of the file that is playing like for example the vlc player does when you increase the volume beyond 100%. It has nothing to do with the volume you set to the phone, it just compensates for files which have a more quiet audio track.
You can try Web Audio API
function amplifyMedia(mediaElem, multiplier) {
var context = new (window.AudioContext || window.webkitAudioContext),
result = {
context: context,
source: context.createMediaElementSource(mediaElem),
gain: context.createGain(),
media: mediaElem,
amplify: function(multiplier) { result.gain.gain.value = multiplier; },
getAmpLevel: function() { return result.gain.gain.value; }
};
result.source.connect(result.gain);
result.gain.connect(context.destination);
result.amplify(multiplier);
return result;
}
You may need to implement a Native Module yourself for js to call setStereoVolume() on your AudioTrack if you are using AudioTrack.Or if you are using ExoPlayer to play music,try implement a custom AudioProcessor to copy each channel and apply the amplification.
We have created an app and for some reason any sound played through Howler that is set to loop has a 30 second or so delay before it actually begins when played on an Android device. Its as if the entire sounds needs to be loaded prior to playing. The sound itself is stored locally on the device and we are using .ogg's. Also this hasn't been an issue before and its only since we updated crosswalk to version 23+ (2.3.0)
Has anybody else come across this or potentially have a fix for this?
Ok so I have found out the issue was to do with Howler and not Crosswalk. Essentially when setting up a new Howl we need to pass the parameter html5:true.
This worked for me:
let gasLooper;
let gasSound = new Howl({
preload:true
, src: require('./assets/audio/Gas-loop.mp3')
, autoplay: true
, volume: 0.5
, onplay: ()=>{
gasLooper = setTimeout(()=>{
gasSound.play();
},450);
}
, onstop: ()=>{
clearTimeout(gasLooper);
}
});
I am developing a karaoke app which consist of animation and playback song. The most important thing here is very precise synchronization between both.
I implemented it few months ago and on iOS 9/10 everything was working great. We had a problem with Android app (ExoPlayer) because there were too big delay between playback and animation. Finally we found out that the problem was caused by wrong song format (mp3) - which was explained here: https://github.com/google/ExoPlayer/issues/3233. We fixed it by packing song into mp4 format (on iOS there is still mp3 used).
I use AVPlayer with HLS
self.player = AVPlayer(url: url)
//
var currentTime_: Double {
if let player = self.player {
return player.currentTime().seconds
}
return 0
}
Everything was ok until iOS 11 release. On iOS 11 there is the same desynchronization (player.currentTime is not accurate) that was on Android.
What's interesting is that even app that was build on iOS 10 SDK and is available on AppStore doesn't work properly on iOS 11 - but it still works great on iOS 10.
Nothing on server side was changed. So Apple had to change something in decoding/buffering. Right now we are working on changing audio format/decoding but still I am curious - why that has happened? Anyone encountered something similar?
Regards
You need use this option when create AVURLAsset
let asset = AVURLAsset(url: url, options: [AVURLAssetPreferPreciseDurationAndTimingKey: true])
If you not use this option, AVPlayer measures mp3 audio duration by file length, so it has small error to get duration.
As woosiki pointed it out, you need to use the AVURLAsset. Just keep in mind that loading of large files will take longer due to the pre-calculation of the precise duration. You may want to put a loader indicator.
func prepareAudioFile(with track: Track) {
guard let url = URL(string: track.streamURL) else {
return
}
let asset = AVURLAsset(url: url,
options: [AVURLAssetPreferPreciseDurationAndTimingKey: true])
let playerItem = AVPlayerItem(asset: asset)
player = AVPlayer(playerItem: playerItem)
observePlayerProgress()
}
private func observePlayerProgress() {
let interval = CMTimeMake(value: 1, timescale: 5)
player.addPeriodicTimeObserver(forInterval: interval, queue: .main) { [weak self] time in
if let track = self?.player.currentItem, track.status == .readyToPlay {
// Once the loading is finished this callback will return
// Here you can calculate and set duration and elapsed time (track.duration, time.seconds)
}
}
}
Good day,
I'm currently building a website for myself (I'm a composer/producer), and I'm using Media Element for the main demo page. The page is under construction at the following link:
http://www.vincentrubinetti.com/listen.html
http://www.vincentrubinetti.com/listen.js
Below are what I think are the relevant functions and code:
function initPlayer()
{
player = new MediaElementPlayer('#listen_player',{
success: function (mediaElement, domObject)
{
mediaElement.addEventListener('play', resumeSong, false);
mediaElement.addEventListener('ended', playNextSong, false);
mediaElement.addEventListener('pause', pauseSong, false);
}
});
[omitted]
}
function setSong(element)
{
if (element != "")
{
unselectAllSongs();
document.getElementById(element).className = "listen_song_highlight";
[omitted]
var newSrc = document.querySelector("#"+element+" .listen_song_source").title;
player.pause();
player.setSrc(newSrc);
player.load();
}
}
function playSong(element)
{
document.querySelector("#"+element+" .listen_song_status").innerHTML = "playing";
player.play();
}
function playNextSong()
{
var newSong = document.querySelector(".listen_song_highlight + div.listen_song");
if (autoplay && newSong != null)
{
setSong(newSong.id);
playSong(newSong.id);
}
else
{
document.querySelector(".listen_song_highlight .listen_song_status").innerHTML = "stopped";
}
}
All the CSS end of this seems to be fine. It finds the next song on the list and sets the new source; I've verified it does this properly via alert and other debugging. However, on the Android default browser and the Dolphin browser, it seems to not be able to load the mp3 sometimes, and prematurely triggers the "ended" event to go to the next song. The result is that it appears to skip 2-3 songs after one is done playing. And it takes some finagling even to get it to play one, clicking on the song divs and the player play button. I can type in the same url that's in the html, and the browser will play/download it just fine, no problems accessing or loading it.
Here are the 3 mp3 files that repeat down the playlist, for reference. They are by me, but are placeholders for the real music.
NEW/music/creation.mp3
NEW/music/startup.mp3
NEW/music/win.mp3
Note that all of this works properly on Chrome, Firefox, IE8+, and Android Chrome (I haven't tested iPhone or iPad yet).
Is my diagnosis correct? Can anyone point me in the right direction? Is there any experience where MediaElement doesn't work properly on the Android default and Dolphin browsers?
I have the same problem in android (but with video...)
I was told that this is an issue with the file not being downloaded in time -- i.e. the browser starts the download, but since the file isn't downloaded it is 0:00 long, so the ended event is triggered.
If there is someway to make it so that the video / audio can be downloaded faster it solves the problem.
Strangely enough, if the device has good WiFi then this problem basically disappears.
See what John Dyer said about it here:
https://github.com/johndyer/mediaelement/issues/543