Let $R$ be a regular $n$-gon, and number the midpoints of its sides $0$ through $n-1$.
Note that if a line passing through the midpoint of a side is parallel to another side, then it passes through the midpoint of another side. For odd $n$ the converse holds; a line passing through the midpoints of two distinct sides is parallel to another side. For even $n$ this only holds if the sides differ by an even number (assuming we have numbered the sides in a sensible way).
Hence we may describe the initial motion as starting from a point $p\in\{0,\ldots,n-1\}$, towards another point $q\in\{0,\ldots,n-1\}$, where $p\neq q$. Denote the path starting from point $p$ moving towards $q$ by $P(p,q)$.
Consider the path $P(0,m)$. After meeting point $m$, the ball is reflected and moves towards point $2m$. By symmetry, the $k$-th point to be met is the point $k\cdot m$, so the points on the path $P(0,m)$ are the integer multiples of $m$, modulo $n$ of course.
Counting orientation, this yields precisely $n-1$ distinct paths meeting $0$ if $n$ is odd, and precisely $\tfrac{n}{2}-1$ distinct paths meething $0$ if $n$ is even. Of course not every path meets the point $0$ necessarily. The length of $P(0,m)$, i.e. the number of distinct points it meets, is $\operatorname{lcm}(m,n)/n$, or equivalently $m/\gcd(m,n)$, whichever you prefer, so there are precisely $\gcd(m,n)$ distinct 'rotations' of this path. The total number of distinct paths, counting orientation, is therefore
$$T(n)=\left\{\begin{array}{cc}
\sum_{m=1}^{n-1}\gcd(m,n)&\text{ for } n \text{ odd,}\\
\sum_{m=1}^{\tfrac{n}{2}-1}\gcd(2m,n)&\text{ for } n \text{ even.}\end{array}\right.$$
This is not as bad as it looks; it turns out these sums are multiplicative. For details, see this question. The accepted answer there shows that if $n=\prod_{p\mid n} p^{n_p}$ then
$$\sum_{m=1}^n\gcd(m,n)=n\prod_{p\mid n}\big(1+n_p(1-\tfrac1p)\big).$$
So indeed this shows that the number of paths on an $n$-sided table is closely related to the factorization of $n$.
Also, if we don't count orientation, we find the total numbers to be
$$t(n)=\left\{\begin{array}{cc}
\frac{1}{2}(T(n)+n)&\text{ if } 4\mid n\\
\frac{1}{2}T(n)&\text{ otherwise}\end{array}\right..$$