- Home /
How to use (AVPro) plugin with JavaScript.
I can't seem to figure out how to use the plugin with JS. I want to get the playbacktime of the video.
http://downloads.renderheads.com/docs/AVProVideoClassReference-1.1.0/interface_render_heads_1_1_media_1_1_a_v_pro_video_1_1_i_media_control.html tells me to use this function: float RenderHeads.Media.AVProVideo.IMediaControl.GetCurrentTimeMs()
There are a bunch of c# examples but nothing for JS. I thought I could just import and access like other functions but that doesn't work the way I expected.
import RenderHeads.Media.AVProVideo;
returns:
BCE0021: Namespace 'RenderHeads.Media.AVProVideo' not found, maybe you forgot to add an assembly reference?
I did find something here: http://docs.unity3d.com/Manual/NativePlugins.html
@DllImport (AVProVideo)
this returns the following error:
BCE0064: No attribute with the name 'DllImport' or 'DllImportAttribute' was found (attribute names are case insensitive). Did you mean 'System.Runtime.InteropServices.DllImportAttribute'?
How should I do this?
$$anonymous$$ake sure the Plugin is put in the right place in the editor.
I'm pretty sure the plugin is in the right place. It's in Assets/Plugins and C# works fine. However I think I'm slowly working towards a solution. I missed the InteropServices.
#pragma strict
import System;
import System.Runtime.InteropServices;
@DllImport ("AVProVideo")
static private function GetDuration$$anonymous$$s() : float {};
This no longer gives an error. Until I call "getDuration$$anonymous$$s()" that is. The new error is: EntryPointNotFoundException: GetDuration$$anonymous$$s
Yeah that was given to you in the error :P
Anyway, just in case it is a Plugin Placement issue, take a gander at this
http://docs.unity3d.com/$$anonymous$$anual/PluginInspector.html
Answer by Wenneker · Apr 12, 2016 at 04:34 PM
It was a combination of issues. Part of it was my code. Part was compilation order and thus a folder issue like @meat5000 suggested.
With the package moved to "Assets/StandardAssets" and the following code it works.
#pragma strict
// Tell it which name space to use
import RenderHeads.Media.AVProVideo;
// We need to set the MediaPlayer that this script uses in the Unity inspector
var player :MediaPlayer;
function Start () {
}
function Update () {
// Check the media player is initialised
if (player != null && player.Control != null){
// Call function to get playback details
var time : float = player.Control.GetCurrentTimeMs();
print("time is: " + time);
}
}
I'm trying to do the same thing, and having a very frustrating time with it.
In hopes of just getting it to work, I've copied your above code entirely, and tried moving the plugin around in the folder structure everywhere I can think of. ...nothing...I still get the "Namespace not found" error.
Is there any way that I can trouble you for a more detailed description of what you've done?
I'm running Windows 7 and Unity 4.7.2, if that helps. Thanks!
I can't really remember exactly. It's been a while. ;)
If you haven't figured it out over the past 2 days I can send you the project I used to test it. Unfortunately it's over the filesize limit for this forum so you'll need to P$$anonymous$$ me a mailaddress and I'll send it with WeTransfer.
Your answer
![](https://koobas.hobune.stream/wayback/20220612074352im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I import and use a plugin/API? 0 Answers
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Windows 8 - DLLNotFoundException. Windows 7 - No problems! 0 Answers
Importing a DLL that contains C#-wrapped C++ Code 0 Answers
Error with Plugin on Windows Phone 8 1 Answer