How to attract student attention in difficult/technical topics
First of all, you can't expect that all students are interested in the same manner. Concentration has its ups and downs over time. Also, some things are dull and will remain so, no matter how good a lecturer presents or how interested the audience is. This doesn't mean that you should skip it on the exam, students just have the choice to absorb it in class or later by themselves.

You seem, however, to face that the majority of students is uninterested. You could try to change the dynamic of class, for example, by going over the "heavy" parts at the beginning. That may include that you pace your schedules so, that that particular part of the curriculum comes at the beginning of the next class. If the "heavy" part is too elaborate, try splitting it into meaningful blocks, that can be intersected by "lighter" material, of course in a meaningful way. Ideal would be blocks that you can cover in 20-25 minutes.

Being a good lecturer is not only about the eloquence of talk or the skill of rhetoric, it is also about understanding that how to "pre-chew" the material for a given audience to keep their attention but still convey the knowledge. Dull things must be included, you can't change that. You can, however, change how you approach them.

PS: I don't think forbidding cells, laptops, youtube, etc. would help very much.