Video not playing from Android

Video not playing from Android

by Jibon Costa -
Number of replies: 5
Hello,

In my moodle course I have few pages with custom html video tag like this:

<video controls="controls" preload="none" >
<source type="video/mp4" src="https://MY_Site/Videos HD/HSK-1-L1-1.1-HD_360.mp4" title="360p">
<source type="video/mp4" src="https://MY_site/Videos HD/HSK-1-L1-1.1-HD_480.mp4" title="480p">
<track kind="subtitles" src="https://MY_site/subtitles/HSK-1-L1-1.1-HD_subtitles_en.srt" srclang="en" label="English">
</video>

During testing with PC's browser the video was playing just fine. But after building app using phonegap it wasn't playing from Android. From iPhone it was playing.

Anyone have any idea?


Thanks

Jibon


Average of ratings: -
In reply to Jibon Costa

Re: Video not playing from Android

by Mohammed Essaid MEZERREG -

We had this problem in our app, we fixed it by using the $sce Angular service , which tell the app that this url or source is trustworthy thus you can use it anywhere in your app.

You can use it like this:

// In you controller:
$scope.srcList = [ 
          {src: $sce.trustAsResourceUrl(srouce one); type: 'video/mp4'},
          {src: $sce.trustAsResourceUrl(source two); type: 'video/flv'},
          {src: $sce.trustAsResourceUrl(source three); type: 'video/webm'} ]; // Assuming you have three sources.


Then you can use it in your view like this:

<video controls="controls" preload="none" >
<!-- You can add the title in the list in your model -->
<source ng-repeat="videoUrl in srcList" type="{{videoUrl.type}}" src="{{videoUrl.src}}" title="videoUrl.title">
<!-- You apply the same thing to the sub-titles -->
</video>

You can also use 

ng-src="videoUrl.src"

If you have live video sources like .m3u8 you can use video.js library to create the player and use its hls plugin to fetch data from your live source.

In reply to Mohammed Essaid MEZERREG

Re: Video not playing from Android

by Jibon Costa -

Thanks for your reply Mohammed. I don't think I can use your solution for page because that code was added manually during adding course. For some reason apps wasn't loading data from https url. It was working fine from PC browser & iPhone. So I have changed all the https to http using replace() function of javascript & it's working now smile

In reply to Jibon Costa

Re: Video not playing from Android

by Mohammed Essaid MEZERREG -

Good to hear about it, but if you have any problems with course content like this one just go to the course core component, in the section.js controller you can add your additional handlers smile.

In reply to Mohammed Essaid MEZERREG

Re: Video not playing from Android

by Jibon Costa -

Thanks for the suggestion. Do you have idea how can I show all the courses list? I mean I want to listed all the courses (not enrolled to user).

In reply to Jibon Costa

Re: Video not playing from Android

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi,

you can't retrieve all the courses from the Moodle site, in order to do that, you will need Moodle 3.2 with the new get_courses_by_field WS

Juan