I am testing a Tab Capture API to record audio of web page that contains a text to speech flash object. while recording a web page the playback audio disappear but sounds OK in the recorded file.
I am using the following MediaStream constraint to record video and audio.
var MediaStreamConstraint = {
audio: true,
video: true,
videoConstraints: {
mandatory: {
chromeMediaSource: 'tab',
minWidth: 640,
maxWidth: 640,
minHeight: 420,
maxHeight: 420
}
}
};
am i missing something in the stream constraint or there is some other solution to the problem?
As others have said, playing the audio from the captured MediaStream in the callback works:
chrome.tabCapture.capture(MediaStreamConstraint, gotStream);
function gotStream(stream) {
window.audio = document.createElement("audio");
window.audio.src = window.URL.createObjectURL(stream);
window.audio.play()
}
Keep in mind to grant permissions in manifest file
"permissions": [
"tabCapture",
"activeTab",
...
],
The background.js should be something like this:
var recorder = new MRecordRTC();
function handleCapture(stream) {
recorder.addStream(stream);
recorder.mediaType = { video: true, audio: true };
recorder.startRecording();
}
var MediaStreamConstraint = {
audio: true,
video: true,
videoConstraints: {
mandatory: {
chromeMediaSource: 'tab',
minWidth: 640,
maxWidth: 640,
minHeight: 420,
maxHeight: 420
}
}
};
function captureCurrentTab() {
chrome.tabCapture.capture(MediaStreamConstraint, handleCapture);
}
function stopCapturing() {
// stops the recording and save audio and video
}
If these are not the case, could you please attach more related codes since the codes you attached look good with me.
In your background script's handleCapture function, try this to continue playback:
var audio = new Audio(window.URL.createObjectURL(stream));
audio.play();
only add the next lines
window.audio = document.createElement("audio");
window.audio.src = window.URL.createObjectURL(stream);
window.audio.play()
Related
Is there a way to get smooth gradient from the lighting?
I'm creating a survival game using PhaserJs 3. I'm using the LightsManager and a tileset I modified from one of the example tilesets included in the examples.
Currently the tile grid is visible because of how the lighting is working with the tiles.
If possible, I would like to have the lighting be smooth similar to the picture below:
My grass tile is 32x32:
and the normal map is the following image
which was generated using this normal map generator site.
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
pixelArt: true,
backgroundColor: '#000000',
scene: {
preload: preload,
create: create,
update: update,
},
physics: {
default: 'arcade',
arcade: {
gravity: { y: 0, x:0 },
debug: false
}
},
};
var light;
var layer;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('tiles', ['assets/tilemap.png','assets/tilemap_n.png']);
...
}
function create ()
{
var level = [ // The grass tile is #29 in the tileset
[29,29,29,29,29,29],
[29,29,29,29,29,29],
[29,29,29,29,29,29],
[29,29,29,29,29,29],
[29,29,29,29,29,29],
[29,29,29,29,29,29]]
var map = this.make.tilemap({ data: level, tileWidth: 32, tileHeight: 32 });
var tiles = map.addTilesetImage('tiles');
layer = map.createStaticLayer(0, tiles, 0, 0).setScale(2)
layer.setPipeline('Light2D');
light = this.lights.addLight(390,223.3, 150).setIntensity(.8);
}
I'm not sure if this is the best (or most performant) way, but you could use this plugin to create a post pipeline blur.
here a working demo of this plugin: https://codepen.io/rexrainbow/pen/zYzzYVw
Basically you would have to load the plugin, in preload:
function preload (){
...
this.load.plugin('rexkawaseblurpipelineplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexkawaseblurpipelineplugin.min.js', true);
}
And apply the plugin in to the specific camera, or gameobject:
function create (){
var postFxPlugin = this.plugins.get('rexkawaseblurpipelineplugin');
var postFxPipeline = postFxPlugin.add(this.cameras.main, {
blur: 1,
quality: 3
});
...
}
Or you could fake, the gradient with multiple lights and may be add a specific ambientColor:
light1 = this.lights.addLight(390,300, 150, 0xffffff, .80);
light2 = this.lights.addLight(390,300, 250, 0xffffff, .75);
light3 = this.lights.addLight(390,300, 350, 0xffffff, .70);
this.lights.enable().setAmbientColor(0x555555);
I'm trying to make a card flip when is touched (working on mobile). So far I've only been able to change one frame for another (front to back), without any transition, so it feels unnatural. The idea is that you touch the screen, a card shows up, then ou touch it again and the card slowly flips, so you can see something in the back of the card.
I'm using the latest iteration of Phaser 3.
I have a working example, but it's made in Phaser 2, so I'm having a really hard time trying to update the code to Phaser 3.
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload() {
this.load.image('fondo', 'img/backgroundhome.png');
this.load.spritesheet('carta', 'img/spritesheet.png', { frameWidth: 196, frameHeight: 339 });
this.load.image('reverso', 'img/reversecard.png');
}
function create() {
this.add.image(400, 300, 'fondo');
let cartaObj = this.add.image(75, 100, 'carta').setOrigin(0, 0).setInteractive();
this.anims.create({
key: 'frente',
frames: this.anims.generateFrameNumbers('carta', { start: 0, end: 0 }),
frameRate: 1,
repeat: -1
});
this.anims.create({
key: 'atras',
frames: this.anims.generateFrameNumbers('carta', { start: 1, end: 1 }),
frameRate: 1,
repeat: -1
});
var tween1 = this.scene.tweens.add({
targets: cartaObj,
scaleX: 10,
scaleY: 10,
ease: 'Linear',
duration: 300,
repeat: 0,
yoyo: false
});
cartaObj.once('pointerup', cargaAnim, this);
}
function cargaAnim() {
tween.start();
}
Tap the screen, show up a card (in this case a have a spritesheet with 2 frames, front and back), tap the card again and it flips slowly to show the back of the card.
I'm not very familiar with Phaser3 yet, but in Phaser2 I made something like this, see the level icons animation in this game. Basically the idea is to:
add a tween to 'fold' the card sprite (scale width to 0.0)
add onComplete function to tween
in onComplete function change sprite frame to show the card and..
..start another tween to 'unfold' the card (scale width to 1.0)
So something like:
// scale horizontally to disappear
var tween1 = this.scene.tweens.add({
targets: cartaObj,
scaleX: 0.01,
ease: 'Linear',
duration: 300,
repeat: 0,
yoyo: false
});
tween1.onComplete.add(function(){this.onTurnCard(cartaObj);}, this);
onTurnCard: function(card) {
// set card face somehow
card.frameName = 'HeartQueen'; // ?
// scale horizontally to re-appear
var twn = this.scene.tweens.add({
targets: card,
scaleX: 1.0,
ease: 'Linear',
duration: 300,
repeat: 0,
yoyo: false
});
// do something on complete
twn.onComplete.add(function(){this.onTurnCardCompleted(card);}, this);
}
onTurnCardCompleted: function(card) {
// do something, show text, add score etc.
if (card.frameName == 'HeartQueen') {
// ?
};
}
I've weirdest problem where I can successfully play 1 shoutcast station and cannot some other using jplayer. This is strange as information of shoutcast server hints on similar configuration:
http://198.27.79.224:9770/
http://108.61.73.119:8128/
I must also note that flash version of jplayer plays both, but html version only plays first one.
Jplayer js looks like this
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1"
}, [
{
title:"#1 Stream",
mp3:"http://108.61.73.119:8128/;stream/1"
},
{
title:"#2 Stream",
mp3:"http://108.61.73.118:8128/;stream/1"
},
{
title:"#3 Stream",
mp3:"http://108.61.73.117:8128/;stream/1"
},
{
title:"#4 Stream",
mp3:"http://198.27.79.224:9770/;stream/1"
},
], {
swfPath: "jplayer",
supplied: "mp3",
wmode: "window",
preload: "none",
//solution: "flash, html",
smoothPlayBar: true,
keyEnabled: true
});
$("#jplayer_inspector_1").jPlayerInspector({jPlayer:$("#jquery_jplayer_1")});
});
//]]>
</script>
Any ideas?
It seems flash version plays all of the streams, but html5 version only selected few. I never got to the bottom of the problem.
Can't figure this out - I simply want it to carrying on playing the next track when a song is finished.. autoplay set to true.. can't see what's throwing this out?
http://bavanandan.co.uk/press/
(I know, it's old, but I was just searching for a solution myself and stumbled upon this.)
How about
var myPlaylist = new jPlayerPlaylist( {
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1" },
[],
{
swfPath: "wolf-jplayer/assets/js/src",
wmode: "window",
ended: function() {
// continouos play
var i = i+1;
myPlaylist.play(i);
}
}); //jPlayerPlaylist
I am playing an audio track in sencha touch. Its working fine.. But I want two things.
1) How to hide audio player and autoplay the sound. For this I tried
autoplay:true, and
hidden:true,
But this is not working ..
2) I want to add a button for sake of playing audio i.e. It contains the text "Tap to Play"
and when it is tapped it turns Pause .. And when pause tapped it turns to Play ..
I have done this but It does not Work well at all.. i.e. first i have to tap play button at the player and then My customize button came into action ..
Kindly help me to get out of this ..
{
xtype: 'audio',
url: 'lib/touch/snd/sound.mp3',
id: 'sound1',
autoplay:true,
hidden:true
},
{
xtype: 'button',
text:'Tap to play audio',
handler: function() {
var container = this.getParent().getParent(),
// use ComponentQuery to get the audio component (using its xtype)
audio = container.down('audio');
audio.toggle();
this.setText(audio.isPlaying() ? 'Pause' : 'Play');
}
}
Please refer to documentation...
link
It should be something like this
{
xtype: 'audio',
url: 'lib/touch/snd/sound.mp3',
id: 'sound1',
autoplay:true,
hidden:true
},
{
xtype: 'button',
text:'Tap to play audio',
handler: function() {
Ext.getCmp('#sound1').play(this,erg); or
Ext.getCmp('#sound1').pause(this,0,erg);
}
}