Categories
discuss

Developer.facebook.com asks for Data Deletion Url

When trying to switch from developer to live mode, developer.facebook.com gave me this warning:
Before switching to live mode, you must provide both a valid Privacy Policy URL and data deletion information. Update this information in Basic Settings on App Dashboard
I have provided my Privacy policy url, but I dont know what to put here:
enter image description here

To be honest, I dont need this for live app, just for fb login on my test app, but when I try to login with Facebook, I got the error This app is still in development mode. Ok fb, I know…

Answer

Fixed by putting the same URL as it’s in a Privacy Policy field.
However, this should not be the right fix. But the app was made for testing purposes only.

Categories
discuss

Streaming Icecast Audio & Metadata with Javascript and the Web Audio API

I’ve been trying to figure out the best way to go about implementing an idea I’ve had for a while.

Currently, I have an icecast mp3 stream of a radio scanner, with “now playing” metadata that is updated in realtime depending on what channel the scanner has landed on. When using a dedicated media player such as VLC, the metadata is perfectly lined up with the received audio and it functions exactly as I want it to – essentially a remote radio scanner. I would like to implement something similar via a webpage, and on the surface this seems like a simple task.

If all I wanted to do was stream audio, using simple <audio> tags would suffice. However, HTML5 audio players have no concept of the embedded in-stream metadata that icecast encodes along with the mp3 audio data. While I could query the current “now playing” metadata from the icecast server status json, due to client & serverside buffering there could be upwards of 20 seconds of delay between audio and metadata when done in this fashion. When the scanner is changing its “now playing” metadata upwards of every second in some cases, this is completely unsuitable for my application.

There is a very interesting Node.JS solution that was developed with this exact goal in mind – realtime metadata in a radio scanner application: icecast-metadata-js. This shows that it is indeed possible to handle both audio and metadata from a single icecast stream. The live demo is particularly impressive: https://eshaz.github.io/icecast-metadata-js/

However, I’m looking for a solution that can run totally clientside without needing a Node.JS installation and it seems like that should be relatively trivial.

After searching most of the day today, it seems that there are several similar questions asked on this site and elsewhere, without any cohesive, well-laid out answers or recommendations. From what I’ve been able to gather so far, I believe my solution is to use a Javascript streaming function (such as fetch) to pull the raw mp3 & metadata from the icecast server, playing the audio via Web Audio API and handling the metadata blocks as they arrive. Something like the diagram below:

Data Processing Block Diagram

I’m wondering if anyone has any good reading and/or examples for playing mp3 streams via the Web Audio API. I’m still a relative novice at most things JS, but I get the basic idea of the API and how it handles audio data. What I’m struggling with is the proper way to implement a) the live processing of data from the mp3 stream, and b) detecting metadata chunks embedded in the stream and handling those accordingly.

Apologies if this is a long-winded question, but I wanted to give enough backstory to explain why I want to go about things the specific way I do.

Thanks in advance for the suggestions and help!

Answer

I’m glad you found my library icecast-metadata-js! This library can actually be used both client-side and in NodeJS. All of the source code for the live demo, which runs completely client side, is here in the repository: https://github.com/eshaz/icecast-metadata-js/tree/master/src/demo. The streams in the demo are unaltered and are just normal Icecast streams on the server side.

What you have in your diagram is essentially correct. ICY metadata is interlaced within the actual MP3 “stream” data. The metadata interval or frequency that ICY metadata updates happen can be configured in the Icecast server configuration XML. Also, it may depend on your how frequent / accurate your source is for sending metadata updates to Icecast. The software used in the police scanner on my demo page updates almost exactly in time with the audio.

Usually, the default metadata interval is 16,000 bytes meaning that for every 16,000 stream (mp3) bytes, a metadata update will sent from Icecast. The metadata update always contains a length byte. If the length byte is greater than 0, the length of the metadata update is the metadata length byte * 16.

ICY Metadata is a string of key=’value’ pairs delimited by a semicolon. Any unused length in the metadata update is null padded.

i.e. "StreamTitle='The Stream Title';StreamUrl='https://example.com';"

read [metadataInterval bytes]        -> Stream data
read [1 byte]                        -> Metadata Length
if [Metadata Length > 0]
   read [Metadata Length * 16 bytes] -> Metadata

byte length response data action
ICY Metadata Interval stream data send to your audio decoder
1 metadata length byte use to determine length of metadata string (do not send to audio decoder)
Metadata Length * 16 metadata string decode and update your “Now Playing” (do not send to audio decoder)

The initial GET request to your Icecast server will need to include the Icy-MetaInt: 1 header, which tells Icecast to supply the interlaced metadata. The response header will contain the ICY metadata interval Icy-MetaInt, which should be captured (if possible) and used to determine the metadata interval.

In the demo, I’m using the client-side fetch API to make that GET request, and the response data is supplied into an instance of IcecastReadableStream which splits out the stream and metadata, and makes each available via callbacks. I’m using the Media Source API to play the stream data, and to get the timing data to properly synchronize the metadata updates.

This is the bare-minimum CORS configuration needed for reading ICY Metadata:

Access-Control-Allow-Origin: '*' // this can be scoped further down to your domain also
Access-Control-Allow-Methods: 'GET, OPTIONS'
Access-Control-Allow-Headers: 'Content-Type, Icy-Metadata'

icecast-metadata-js can detect the ICY metadata interval if needed, but it’s better to allow clients to read it from the header with this additional CORS configuration:

Access-Control-Expose-Headers: 'Icy-MetaInt'

Also, I’m planning on releasing a new feature (after I finish with Ogg metadata) that encapsulates the fetch api logic so that all a user needs to do is supply an Icecast endpoint, and get audio / metadata back.

Categories
discuss

Stack doesn’t work inside Column – Flutter

Hope u all doing well. I have a problem with Stack and Column. When I want to use Stack inside Column’s children, it doesn’t work, anymore. here are 2 photos regarding my problem.

Not working:
enter image description here


Working:
enter image description here

Answer

Since column and stack will take up the screen size. To be able to use both together, you need to give the contents a certain height or need to be wrapped with expanded

column(
   children[
  container(height:100 child:stack..... //container or expanded
   ])
Categories
discuss

Change CodeStar Spring MVC project to Spring Boot

I have a Spring Boot project that works perfectly when run in IDE. I would like to run this via AWS CodeStar. Unfortunately, the default Spring template created by CodeStar uses Spring MVC.

I cannot just overwrite the default Spring MVC project with my Spring Boot project (it doesn’t work). I can copy some of my resources to the MVC project, for example index.html and that works. But then features like Thymeleaf don’t work. For this and other reasons, I would like to change the provided Spring MVC into the Spring Boot structure I already have.

I followed the instructions here: https://www.baeldung.com/spring-boot-migration

Unfortunately, this doesn’t help. I can create Application Entry Point and add Spring Boot dependencies without the app breaking. But when I remove the default dependencies or the configuration associated with the MVC, the app breaks. When trying to reach the URL, I get a 404 error with description:

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Debugging this error message (e.g. https://www.codejava.net/java-ee/servlet/solved-tomcat-error-http-status-404-not-found) didn’t help.

The message seems like it’s connected to the web resource. I have my web resources in folder resources as well as webapp/resources. And Spring Boot doesn’t need any location configuration, right? It uses this location by default.

Can somebody tell me what things to remove and what to add to be able to use my existing Spring Boot project?

EDIT:

This is a link to a default template for AWS CodeStar Spring web application: https://github.com/JanHorcicka/AWS-codestar-template

And this is my Spring Boot project structure:

Structure

Answer

I realize that you indicated that previously you tried to use your Spring Boot project with some modifications without success, but I think it could be actually a possibility to successfully deploy your application on AWS CodeStar, and it will be my advice.

I also realized that in your screenshot you included several of the required artifacts and classes, but please, double check that you followed these steps when you deployed your application to AWS CodeStar.

Let’s start with a pristine version of your Spring Boot project running locally, without any modification, and then, perform the following changes.

First, as indicated in the GitHub link you shared, be sure that you include the following files in your project. They are required for the deployment infrastructure of AWS:

  • appspec.yml
  • buildspec.yml
  • template.yml
  • template-configuration.json
  • The whole scripts directory

Please, adapt any necessary configuration to your specific needs, especially, template-configuration.json.

Then, perform the following modifications in your pom.xml. Some of them are required for Spring Boot to work as a traditional deployment and others are required by the deployment in AWS CodeStar.

Be sure that you indicate packaging as war:

<packaging>war</packaging>

To ensure that the embedded servlet container does not interfere with the Tomcat to which the war file is deployed, either mark the Tomcat dependency as being provided as suggested in the above-mentioned documentation:

<dependencies>
    <!-- … -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- … -->
</dependencies>

Or exclude the Tomcat dependency in your pom.xml:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>

If necessary, apply this exclusion using some kind of profile that allows you to boot Spring Boot locally and in an external servlet container at the same time.

Next, parameterize the maven war plugin to conform to the AWS CodeStar deployment needs:

<build>
    <pluginManagement>
        <plugins>
          <!-- ... -->
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <version>3.2.2</version>
              <configuration>
                  <warSourceDirectory>src/main/webapp</warSourceDirectory>
                  <warName>ROOT</warName>
                  <failOnMissingWebXml>false</failOnMissingWebXml>
              </configuration>
          </plugin>
          <!-- ... -->
       <plugins>
    </pluginManagement>
</build>

I do not consider it necessary, but just to avoid any kind of problem, adjust the name of your final build:

<finalName>ROOT</finalName>

Lastly, as also indicated in the Spring documentation, be sure that your MyProjectApplication – I assume this class is your main entry point subclass SpringBootServletInitializer and override the configure accordingly, something like:

@SpringBootApplication
public class MyProjectApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(MyProjectApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(MyProjectApplication.class, args);
    }

}

Please, feel free to adapt the class to your specific use case.

With this setup, try to deploy your application and see if it works: perhaps you can find some kind of library dependencies problem, but I think for the most part it should work fine.

At a first step, you can try to deploy locally the version of the application you will later deploy to AWS CodeStar following the instructions you provided in your project template, basically, once configured with the necessary changes described in the answer, by running:

mvn clean package

And deploying the generated war on your local tomcat environment. Please, be aware that probably the ROOT application already exists in a standard tomcat installation (you can verify it by inspecting the webapps folder): you can override that war file.

For local testing you can even choose a different application name (configuring build.finalName and the warName in your pom.xml file): the important thing is verify if locally the application runs successfully.

If you prefer to, you can choose to deploy the app directly to AWS CodeStar and inspect the logs later it necessary.

In any case, please, pay attention on two things: on one hand, if you have any absolute path configured in your application, it can be the cause of the 404 issue you mention in the comments. Be aware that your application will be deployed in Tomcat with context root ‘/’.

On the other hand, review how you configured your database access. Probably you used application.properties and it is fine, but please, be aware that when employing the application the database must be reachable: perhaps Spring is unable to create the necessary datasources, and the persistence manager or related stuff associated with and, as a consequence, the application is not starting. Again, it may be the reason of the 404 error code.

To simplify database connectivity, for testing, at first glance, I recommend you to use simple properties for configuring your datasource, namely the driver class, connection string, username and password. If that setup works properly, you can later enable JNDI or what deemed necessary.

Remember that if you need to change your context name and/or define a datasource pool in Tomcat you can place a context.xml file under a META-INF directory in your web app root path.

This context.xml should look like something similar to:

<?xml version="1.0" encoding="UTF-8"?> 
<Context path="/"> 

  <Resource name="jdbc/myDS" 
    type="javax.sql.DataSource"
    maxActive="100" 
    maxIdle="30" 
    maxWait="10000" 
    url="jdbc:mysql://localhost:3306/myds" 
    driverClassName="com.mysql.jdbc.Driver" 
    username="root" 
    password="secret" 
  /> 

</Context>
Categories
discuss

Invariant Violation: Tried to register two views with the same name RNCAndroidDropdownPicker

After importing and using the module react-native-picker:

import {Picker} from '@react-native-picker/picker';
 <Picker
    selectedValue={this.state.language}
    style={{height: 50, width: 100}}
    onValueChange={(itemValue, itemIndex) =>
              this.setState({language: itemValue})
        }>
    <Picker.Item label="Java" value="java" />
    <Picker.Item label="JavaScript" value="js" />
 </Picker>   

I get the following error:

Invariant Violation: Tried to register two views with the same name RNCAndroidDropdownPicker

What went wrong here?

Answer

To get rid of that, do the following:

Since the error is about registering two views with the same name, declare your Picker in this way:

import { Picker as SelectPicker } from '@react-native-picker/picker';

instead of import { Picker } from '@react-native-picker/picker';

and implement like this:

<SelectPicker
  selectedValue={this.state.language}
  style={{ height: 50, width: 100 }}
  onValueChange={(itemValue, itemIndex) =>
    this.setState({ language: itemValue })
  }>
  <SelectPicker.Item label="Java" value="java" />
  <SelectPicker.Item label="JavaScript" value="js" />
</SelectPicker>

If the above solution doesn’t work, do this

$ npm uninstall --save-dev @react-native-picker/picker
$ npm i @react-native-picker/picker --save
$ cd android
$ ./gradlew clean
$ cd ..
$ react-native run-android

Update:

This is the issue with native-base. Uninstall native-base and reinstall like this:

$ npm uninstall native-base --save
$ npm install native-base --save

This issue has been fixed in the latest release of native-base.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..