Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Mediacapture plugin recorders: Difference between revisions

From MoodleDocs
(Created page with "== Introduction == Mediacapture is a repository plugin which allows recorders to record and upload audio/video content to Moodle easily. ===Overview=== The 3 different parts t...")
 
No edit summary
Line 15: Line 15:


== Example ==
== Example ==
*[[Nanogong Mediacapture Plugin|Nanogong Mediacapture Plugin]]
*[[Nanogong Recorder [https://github.com/ankitdbst/repository_mediacapture/recorders/nanogong]]]
*[[Local Audio Recorder Mediacapture Plugin|Local Audio Recorder Mediacapture Plugin]]
*[[Local Audio Recorder [https://github.com/ankitdbst/repository_mediacapture/recorders/localaudiorecorder]]]
*[[Red5Recorder Mediacapture Plugin|Red5Recorder Mediacapture Plugin]]
*[[Red5-Recorder [https://github.com/ankitdbst/repository_mediacapture/recorders/red5recorder]]]


== Template ==
== Template ==
Line 41: Line 41:
For example:
For example:
<code php>
<code php>
    public static function get_type_option_names() {
public static function get_type_option_names() {
        array('myrecorder', 'config');
    array('myrecorder', 'config');
    }
}
</code>
</code>


Line 51: Line 51:
For example, to display the standard repository mediacapture plugin settings along with the custom ones for the recorders use:
For example, to display the standard repository mediacapture plugin settings along with the custom ones for the recorders use:
<code php>
<code php>
    public function type_config_form($mform) {
public function type_config_form($mform) {
        $mform->addElement('advcheckbox', 'myrecorder', get_string('nanogong', 'repository_mediacapture'), null, array('group' => 1));
    $mform->addElement('advcheckbox', 'myrecorder', get_string('nanogong', 'repository_mediacapture'), null, array('group' => 1));
    }
}
</code>
</code>


Line 62: Line 62:


====view($mform, $options)====
====view($mform, $options)====
Use this function to display the view of the recorder using the $mform (moodle form).
Use this function to display the view of the recorder using the $mform (moodle form). The object code
for recorders can be embedded by using the 'html' tag for $mform.
The form elements *must* contain the required paramters by mediacapture plugin viz filename, filepath and filetype.


With the example above, this function may look like:
With the example above, this function may look like:
<code php>
<code php>
    public static function view($mform, $options) {
public static function view($mform, $options) {
        $mform->addElement('text', 'filename', get_string('name', 'repository_mediacapture'));
    $recorderhtml = '<object></object>';
        $mform->addElement('submit', 'save', get_string('save', 'repository_mediacapture'));
    $mform->addElement('html', $recorderhtml);
    }
    $mform->addElement('hidden', 'filepath', '');
    $mform->addElement('hidden', 'filetype', 'xyz');
    $mform->addElement('text', 'filename', get_string('name', 'repository_mediacapture'));
    $mform->addElement('submit', 'save', get_string('save', 'repository_mediacapture'));
}
</code>
</code>


Line 76: Line 82:


<code php>
<code php>
    public function post_url() {
public function post_url() {
        return new moodle_url("$CFG->wwwroot/repository/mediacapture/recorders/myrecorder/record.php");
    return new moodle_url("$CFG->wwwroot/repository/mediacapture/recorders/myrecorder/record.php");
    }
}
</code>
</code>


Line 85: Line 91:


<code php>
<code php>
    public function string_keys() {
public function string_keys() {
        return array('appletnotfound', 'norecordingfound', 'nonamefound');
  return array('appletnotfound', 'norecordingfound', 'nonamefound');
 
}
    }
</code>
</code>


Line 96: Line 101:


<code php>
<code php>
    public function min_version() {
public function min_version() {
        return array('java' => 1.5);
  return array('java' => 1.5, 'flash' => 11);
    }
}
</code>
</code>


Line 105: Line 110:


<code php>
<code php>
    public function supported_media() {
public function supported_media() {
        return array('audio', 'video');
    return array('audio', 'video');
    }
}
</code>
</code>


Line 115: Line 120:


<code php>
<code php>
    public function supported_types() {
public function supported_types() {
        return array('java', 'flash', 'html5');
    return array('java', 'flash', 'html5');
    }
}
</code>
</code>



Revision as of 03:22, 9 August 2012

Introduction

Mediacapture is a repository plugin which allows recorders to record and upload audio/video content to Moodle easily.

Overview

The 3 different parts to write

  1. Administration - You can customise the way administrators and users can configure their recorders.
  2. Recorder display - You can also customize the view of the recorders.
  3. I18n - Internationalization should be done at the same time as you're writing the other parts.

History

Mediacapture plugin exists from 2.3

Example

  • [[Nanogong Recorder [1]]]
  • [[Local Audio Recorder [2]]]
  • [[Red5-Recorder [3]]]

Template

There is a template available in [4]

File structure

  1. Create a folder for your plugin in moodle/repository/mediacapture/recorders e.g. moodle/repository/mediacapture/recorders/myrecorder
  2. Create the following files and add them to the myrecorder folder:
    • lib.php, the main class will be named "repository_mediacapture_myrecorder"
  3. Create the language file repository_mediacapture_myrecorder.php and add it to the plugin folder, keeping the following folder structure:
    • moodle/repository/mediacapture/myrecorder/lang/en/repository_mediacapture_myrecorder.php
  4. Create module.js and styles.css (optional)

Administration APIs

Functions you *MUST* override

get_type_option_names

This function must be declared static
Return an array of string. These strings are setting names. These settings are shared by all instances.

For example: public static function get_type_option_names() {

   array('myrecorder', 'config');

}

add_config_form(&$mform)

This is for modifying the Moodle form displaying the recorder settings.

For example, to display the standard repository mediacapture plugin settings along with the custom ones for the recorders use: public function type_config_form($mform) {

   $mform->addElement('advcheckbox', 'myrecorder', get_string('nanogong', 'repository_mediacapture'), null, array('group' => 1));

}

Mediacapture recorder APIs

Functions you *MUST* override

view($mform, $options)

Use this function to display the view of the recorder using the $mform (moodle form). The object code for recorders can be embedded by using the 'html' tag for $mform. The form elements *must* contain the required paramters by mediacapture plugin viz filename, filepath and filetype.

With the example above, this function may look like: public static function view($mform, $options) {

   $recorderhtml = '<object></object>';
   $mform->addElement('html', $recorderhtml);
   $mform->addElement('hidden', 'filepath', );
   $mform->addElement('hidden', 'filetype', 'xyz');
   $mform->addElement('text', 'filename', get_string('name', 'repository_mediacapture'));
   $mform->addElement('submit', 'save', get_string('save', 'repository_mediacapture'));

}

post_url()

Use this function when you need to post the recorded data to a file where it can be moved to a temp location in moodle (data root).

public function post_url() {

   return new moodle_url("$CFG->wwwroot/repository/mediacapture/recorders/myrecorder/record.php");

}

string_keys()

You may list the strings used by your plugin here.

public function string_keys() {

  return array('appletnotfound', 'norecordingfound', 'nonamefound');

}

min_version()

This function will return an array structure listing the min version of various media supported by the recorder.

public function min_version() {

  return array('java' => 1.5, 'flash' => 11);

}

supported_media()

This function will return list of media supported by the recorder.

public function supported_media() {

   return array('audio', 'video');

}

supported_types()

This function will return list of technologies used by the recorder. supported by recorder.

public function supported_types() {

   return array('java', 'flash', 'html5');

}

See also