shockwave activex plugin load flash then call video-js-swf function

166 Views Asked by At

Env: win10,vs2015,adobe flash 26,.net framework 4.

I try to load video-js-swf in MFC application in 'ActiveX' way.I alread load the .swf file with code in MFC.

CString str = _T("path.swf");
m_flash.LoadMovie(0, str);

But I can't use m_flash.CallFunction() to call the function inside .swf file,here is my code:

CString temp = _T("<invoke name=\"vjs_getProperty\" returntype=\"xml\"><arguments><string>defaultPlaybackRate</string></arguments></invoke>");
CString test = m_flash.CallFunction(temp);

the .swf project main code as: VideoJS.as

Do anyone know how to solve this problem?How can I call function inside .swf?

1

There are 1 best solutions below

0
Jeff Q On

I think I figure it out.It's all about the xml string. In my case, I use:

CString temp = _T("<invoke name=\"vjs_getProperty\" returntype=\"xml\"><arguments><string>defaultPlaybackRate</string></arguments></invoke>");
CString test = m_flash.CallFunction(temp);

It's report an error.But when I use:

CString temp = _T(R"(<invoke name="vjs_getProperty" returntype="xml"><arguments><string>defaultPlaybackRate</string></arguments></invoke>)");
CString test = m_flash.CallFunction(temp);

or:

CString temp = _T(R"(<invoke name="vjs_getProperty" returntype="xml"><arguments><string>!CDATA[[defaultPlaybackRate]]</string></arguments></invoke>)");
CString test = m_flash.CallFunction(temp);

It's OK. I think the problem is the flash xml parser.The parser analyzes the string in strange way.By the way, seems <arguments></arguments> must in same line.

However, There is a new bug, memory leak. In visual studio debug mode,the application can't exit normally. Fix memory leak bug: change the code

https://github.com/videojs/video-js-swf/blob/master/src/com/videojs/providers/RTMPVideoProvider.as (line:349)

if(_isPlaying){
     _ns.close();
     _isPlaying = false;
     _hasEnded = true;
     _reportEnded = true;
     _model.broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent.ON_STREAM_CLOSE, {}));
    _throughputTimer.stop();
    _throughputTimer.reset();
}

REPLACE by

if(_isPlaying){
    _ns.close();
    _videoReference.attachNetStream(null);
    _isPlaying = false;
    _hasEnded = true;
    _reportEnded = true;
    _model.broadcastEvent(new VideoPlaybackEvent(VideoPlaybackEvent.ON_STREAM_CLOSE, {}));
    _throughputTimer.stop();
    _throughputTimer.reset();
    _videoReference.clear();
    _nc.close();
}

THEN

complie to .SWF file