I am working on a simple nuxt.js project that plays two audio files and asks the user to determine the audio interval between them. I am currently unable to play any audio files. I took in this solution (https://nuxtjs.org/docs/features/configuration/#extend-webpack-to-load-audio-files) but its not working
also I added in nuxt.config.js
loaders: {
vue: {
transformAssetUrls: {
audio: 'src',
},
},
},
extend(config, ctx) {
config.module.rules.push({
test: /\.(ogg|mp3|wav|mpe?g)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
})
}
and here my code
<div class="col-sm-12 col-sm-offset-2">
<audio
src="#/assets/audios/podcast1.mp3"
controls
class="audio my-3"
></audio>
</div>
I disabled the esmodule then my audio file working
In nuxtconfigure do like this
extend(config, ctx) {
config.module.rules.push({
test: /\.(ogg|mp3|wav|mpe?g)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
esModule: false,
I have a similar problem. But in my case, I play the sound alert from the code.
This code worked previously:
const audio_file = require('#/assets/beeps/some_beep.mp3')
const beep = new Audio(audio_file)
beep.play()
But after the update stopped working.
Fix the problem helped:
const audio_file = require('#/assets/beeps/some_beep.mp3').default
I learned it here:
https://amjohnphilip.medium.com/how-to-work-with-audio-files-in-nuxt-js-8da7abb3c5bb
Related
My webpack source maps are having some very unexpected behaviour when debugging in chrome.
When I hover over something I get this odd problem as can be seen in this screenshot (in the picture the mouse is hovering over props in this.props)
Notice how in the image I can type this.props in console and it correctly shows the values.
It also does not put the breakpoints on many lines but rather put them somewhere else.
Finally and maybe most crucially.
On a line like this: <QuizQuestionImage updateQuestionIdHandler={(newQuestionId) => this.updateQuestionIdHandler(newQuestionId)} /> I can put a breakpoint. And when the code is working that triggers as it should when updateQuestionIdHandler is called. However, if the method that is called, this is: this.updateQuestionIdHandler(newQuestionId) has an error, then the breakpoint is not hit correctly but rather the error is spit out in console.
This despit that it should have breaked before entering that function that in turn gave an error.
This is my webpack config.
const path = require('path');
module.exports = {
context: path.join(__dirname, 'Scripts', 'react'),
entry: {
client: './client'
},
output: {
path: path.join(__dirname, 'Scripts', 'app'),
filename: '[name].bundle.min.js'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: [require('#babel/plugin-proposal-object-rest-spread')],
presets: ["#babel/es2015", "#babel/react", "#babel/stage-0"]
}
}
}
]
},
resolve: {
extensions: ['.js', '.jsx']
},
externals: {
react: 'React'
},
devtool: 'source-map'
};
Running webpack with "-d" param gives a second set of source maps in chrome that tend to work much better.
When running an application that is built using webpack 2, sourcemaps are detected in chrome but original source is not loaded.
I'm using webpack beta21.
These files used to be detected automatically, ie when a breakpoint was put in the the output from webpack js file, the source view would jump to the original source input to webpack. But now I am stuck with this screen:
config:
var path = require("path");
var webpack = require("webpack");
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const PATHS = {
app: path.join(__dirname, '../client'),
build: path.join(__dirname, '../public')
};
module.exports = {
entry: {
app: PATHS.app + '/app.js'
},
output: {
path: PATHS.build,
filename: '[name].js'
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.js?$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, 'client'),
],
exclude: /node_modules/
},
{
test: /\.css/,
loader: "style!css"
}
]
},
resolve: {
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json']
} ,
plugins: [
new WebpackBuildNotifierPlugin()
]
};
Generated files with source maps won't automatically redirect to their original files, because there's potentially a 1-to-many relationship.
If you see the message Source Map Detected, the original file should already appear on the side file tree or the file explorer via Crl + P. If you don't know the original file name, you can open the source map file itself.
The source map path can be identified by a //# sourceMappingURL= comment or the X-SourceMap header:
Open up the source map via url and look for the sources property for the original file name:
The original file should be visible in the sources panel:
If you don't see the message Source Map Detected
You can manually add an external source map by right clicking and selecting Add Source Map:
Additional Resources
If that still doesn't work, you can try a Source Map Validator
For webpack specifically, you can configure the devtool property
If you're mapping to a workspace, that means you already have the source code. Including the source code in your source map is creating an unnecessary redundancy.
Use nosources-source-map instead.
The issue with external source maps was fixed in Chrome 52 but it looks like you've got your devtool set differently from mine, I use:
devtool: '#source-maps'
How are you building your source? If you're running with -d it will switch to inline source maps
I've written a very simple little Angular2 app that I've built to generate exercise sheets. However it seems that when I deploy the app ngIf doesn't work (either my ISP default webserver or my own Heroku/local deployed node-http-server). When I run the exact same code base on my dev node server (npm start) ngIf works as expected.
If anyone has some guidance on how I can debug this I would be extremely grateful, or if I'm just plain doing something wrong...
Here's the relevant code
src/template.html
Click on the top left word <span *ngIf="word">({{word}})</span><span *ngIf="!word">(<click>)</span>
app.ts
import {bootstrap} from 'angular2/platform/browser'
import {enableProdMode, Component} from 'angular2/core'
enableProdMode()
#Component({
selector: 'app',
templateUrl: 'src/template.html'
})
export class AppComponent {
public word = '';
}
bootstrap(AppComponent)
When the app starts locally I see "Click on the top left word (<click>)" (as seen in this plunker link), however when I deploy the app I just see "Click on the top left word". I have previously found similar issues with ngFor in deployment. I do however see the following code in both dev and deploy
<!--template bindings={}-->
<!--template bindings={}-->
so the template is being processed, at least to some extent. My best guess is that something must be going wrong when I generate the bundle.js or dependencies.js files through gulp. I don't see any Javascript errors on the dev or deploy site via Chrome dev console though.
Here are some of the relevant tasks from my gulpfile.
gulp.task('webpack', ['clean'], function() {
return gulp.src('src/app/app.ts')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('src/'));
});
gulp.task('dependencies', function() {
return gulp.src(['node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js'])
.pipe(concat('dependencies.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/'));
});
I'm using Angular2.0.0-beta.7. My gulp deployment pipeline also uses Webpack1.12.2 with the following config:
webpack.config.js
module.exports = {
entry: './src/app/app',
output: {
path: __dirname + '/src', publicPath: 'src/', filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.ts']
},
module: {
loaders: [{
test: /\.ts/, loaders: ['ts-loader'], exclude: /node_modules/
}]
}
};
Thanks to #EricMartinez's debug suggestion the app now works. The problem lies with the mangling of the uglified javascript code. (I'll try and trace back what actually goes wrong during the processing of the concatenated JavaScript file.) For now turning the mangling off in uglify() does the trick, but of course I don't have obscuration of the code anymore (which isn't an issue for my particular implementation). Here's the fix:
gulpfile.js
gulp.task('js', ['webpack'], function() {
return gulp.src('src/bundle.js')
.pipe(uglify({ mangle: false })) // <- added mangle option set to false
.pipe(gulp.dest('dist/'));
});
The original code looked like this
gulp.task('js', ['webpack'], function() {
return gulp.src('src/bundle.js')
.pipe(uglify())
.pipe(gulp.dest('dist/'));
});
See this issue on github for more.
I am trying to extract a videolink from a streaming website.
So I use PHP and "file_get_contents" to open the videolink and then "explode" to find the link to the generated link
Its looks like config5/videoid/generatedhash/ but you can access it also with config5/videoid/
So when I open this link I see this:
document.write('<div id="mediaspace2" style="width:880px;height:495px">');
jwplayer.key="key";
document.write('<div id="mediaspace" itemprop="video"></div>');
var scrwid=window.screen.width;
var def=false;
if(scrwid<1200) def=true;
jwplayer("mediaspace").setup({
sources: [{
file: "http://linkto.mp4",
label: "1080p HD",
type: "mp4"
}
,{
file: "http://linkto.mp4",
label: "720p HD",
type: "mp4",
} ,{
file: "http://linkto.mp4",
label: "360p",
type: "mp4",
"default": def
}
and a lot more stuff
when i copy one link of my choice and open it in chrome everything is fine. but when i try to embed it with html5 video tags it opens a file named na.flv
ist like a security for the website
how can i decrypt it? :/
I've got some js code in a chrome background extension of the following :
function handleCapture(stream) {
console.log('content captured');
console.log("backround.js stream: ", stream);
alert(stream);
// localStream = stream; // used by RTCPeerConnection addStream();
// initialize(); // start signalling and peer connection process
}
function captureCurrentTab() {
console.log('reqeusted current tab');
chrome.tabs.getSelected(null, function(tab) {
console.log('got current tab');
var selectedTabId = tab.id;
chrome.tabCapture.capture({
audio : false,
video : true
}, handleCapture);
});
}
However, when this is ran, the "handleCapture" variable "stream" that is passed in is always undefined? Is this to be expected or is there something that I am missing here?
Also, I've confirmed that my manifest.json contains the capture permission and I am using chrome canary Version 31.0.1607.1 canary Aura.
Thanks,
Mike
I had this same issue when I was trying to drive a tabCapture purely from a background script, I found this on the tabCapture reference page:
Captures the visible area of the currently active tab. This method can only be used on the currently active page after the extension has been invoked, similar to the way that activeTab works. Note that Chrome internal pages cannot be captured.
My understanding is that this means you need to drive it from a browserAction for your extension, like so:
chrome.browserAction.onClicked.addListener(function(request) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabCapture.capture({audio: true, video: true}, callback);
});
});
That's what worked for me.
You should probably provide some constraints to make it work. See:
http://developer.chrome.com/extensions/tabCapture.html#type-MediaStreamConstraint
The capture param you provided is a MediaTrackConstraint, see:
http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamconstraints
that is also a simple JS object, where you should set some mandatory options, see:
http://dev.w3.org/2011/webrtc/editor/getusermedia.html#idl-def-MediaTrackConstraints
So the following should help, if you set all the needed settings in mandatory object:
chrome.tabCapture.capture({
audio : false,
video : true,
videoConstraints: {
mandatory: {
width: { min: 640 },
height: { min: 480 }
}
}
}, handleCapture);