4. As shown in Figure 2, given that $A B$ is the diameter of $\odot O$, chord $C D$ intersects $A B$ at point $E$, a tangent line through $A$ intersects the extension of $C D$ at point $F$, and $D$ is the midpoint of $E F$. If $D E=\frac{3}{4} C E, A C=$ $8 \sqrt{5}$, then $A B=$ . $\qquad$
4.24.

Let $C E=4 x, A E=y$. Then
$$
D F=D E=3 x, E F=6 x \text {. }
$$

Connect $A D, B C$.
Since $A B$ is the diameter of $\odot O$ and $A F$ is the tangent of $\odot O$, we have
$$
\angle E A F=90^{\circ}, \angle A C D=\angle D A F \text {. }
$$

Since $D$ is the midpoint of the hypotenuse $E F$ of the right triangle $\triangle A E F$,
$$
\begin{array}{l}
D A=D E=D F \\
\Rightarrow \angle A F D=\angle D A F=\angle A C F \\
\Rightarrow A F=A C=8 \sqrt{5} .
\end{array}
$$

In the right triangle $\triangle A E F$, by the Pythagorean theorem,
$$
E F^{2}=A E^{2}+A F^{2} \Rightarrow 36 x^{2}=y^{2}+320 \text {. }
$$

Let $B E=z$.
Since $\triangle A D E \backsim \triangle C B E$, we have
$$
\frac{A D}{B C}=\frac{D E}{B E}=\frac{A E}{C E} \text {. }
$$

Thus, $B C=C E$, and
$$
\begin{array}{l}
C E \cdot D E=A E \cdot B E \\
\Rightarrow y z=4 x \cdot 3 x=12 x^{2} .
\end{array}
$$

Therefore, $y^{2}+320=3 y z$.
In the right triangle $\triangle A C B$, by the Pythagorean theorem,
$$
A B^{2}=A C^{2}+B C^{2} \Rightarrow(y+z)^{2}=320+z^{2} \text {. }
$$

Thus, $y^{2}+2 y z=320$.
Solving equations (1) and (2) simultaneously, we get $y=8, z=16$.
Therefore, $A B=A E+B E=24$.