1. When writing an XML layout, the [accessibility] missing contentdescription attribute on image warning is always displayed.
Solution:
<ImageView android:layout_width="210dp" android:layout_height="32dp" android:layout_centerHorizontal="true" />
To:
<Imageview Android: layout_width = "210dp" Android: layout_height = "32dp" Android: layout_centerhorizontal = "true" Android: contentdescription = "component description"/>
2. When writing a layout in Android, we sometimes need to encapsulate a class into a component for use. There are two methods embodied in the interface: 1. XML layout, 2. code Writing
First: XML Layout
Pay attention to two points for XML layout.
A. The class constructor must be added.
Public Class Name (context, attributeset attribute ){}
B. the XML format is as follows:
<Package name. Class Name attribute/>
The second code layout, which only needs to be constructed
Public Class Name (context ){}
3. Use audiotrack to play audio. However, multiple audiotrack. Play and audiotrack. Stop operations may occur as follows:
obtainBuffer() track 0x17c418 disabled, restarting
The reason is:
Use audiotrack in a loop. write (byte [] audiodata, int offsetinbytes, int sizeinbytes) when writing audio data, the audio data is not sent in time due to network reasons and Data Processing code logic disorder.
Solution:
This method may be limited to the solutions that currently generate this phenomenon:
Description: uses a socket to receive AAC data. I take a frame and use faad to decode it into a PCM code stream and play it in audiotrack. However, I initialize audiotrack first. play, then receive AAC data, call faad to decode the PCM data, and write the PCM Data to audiotrack to play the sound.
Solution:
The reason for this problem has been written above. Because the data is not written in time, I only initialize the audiotrack instance, but do not perform audiotrack immediately. play (), which is used for audiotrack only when data is sent for the first time. play, which solves my current problem.
/** Play audio */Public void playvideo (byte [] data) {If (appinfortosystem. islistening & aaudio! = NULL & aaudio. getplaystate () = audiotrack. playstate_stopped) {aaudio. play (); aaudio. write (data, 0, 8192);} else if (appinfortosystem. islistening & aaudio! = NULL & aaudio. getplaystate () = audiotrack. playstate_playing) {aaudio. Write (data, 0, 8192 );}}