gpt4 book ai didi

javascript - 如何通过Flash保存录制的音频,文件名通过chrome中的javascript传递

转载 作者:行者123 更新时间:2023-11-28 08:35:35 25 4
gpt4 key购买 nike

我想使用 Flash 播放器保存录制的音频,文件名通过 javascript 传递我尝试过各种方法,例如 How to pass Object tag PARAM value into Flash? & How to read the param value from the object tag using javascript ,但他们都不适合我

我有一个嵌入.swf的javascript,其中AudioRecorder.swf是我的闪存录音机,并且recordedFileName是动态分配的。(引用:http://code.google.com/p/swfobject/wiki/documentation)

swfobject.embedSWF("AudioRecorder.swf", "myAlternativeContent", "350px", "350px", "9.0.0", "expressInstall.swf", RecordFileName, "fileName", "");

HTML 代码:

<div id="myAlternativeContent">
<a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash Players</a>
</div>

AudioRecorder.swf 代码:(引用:http://dev.tutsplus.com/tutorials/create-a-useful-audio-recorder-app-in-actionscript-3--active-5836 )

public class Main extends Sprite
{
private var mic:Microphone;
private var waveEncoder:WaveEncoder = new WaveEncoder();
private var recorder:MicRecorder = new MicRecorder(waveEncoder);
private var recBar:RecBar = new RecBar();
private var tween:Tween;
private var fileReference:FileReference = new FileReference();


public var recordedFileName:String;

public function Main():void
{
recordedFileName = this.loaderInfo.parameters.fileName;

trace(recordedFileName);
recButton.stop();
activity.stop();

mic = Microphone.getMicrophone();
mic.setSilenceLevel(0);
mic.gain = 100;
mic.setLoopBack(true);
mic.setUseEchoSuppression(true);
Security.showSettings("2");

addListeners();
}

private function addListeners():void
{
recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);
recorder.addEventListener(RecordingEvent.RECORDING, recording);
recorder.addEventListener(Event.COMPLETE, recordComplete);
activity.addEventListener(Event.ENTER_FRAME, updateMeter);
}

private function startRecording(e:MouseEvent):void
{
if (mic != null)
{
recorder.record();
e.target.gotoAndStop(2);

recButton.removeEventListener(MouseEvent.MOUSE_UP, startRecording);
recButton.addEventListener(MouseEvent.MOUSE_UP, stopRecording);

addChild(recBar);

tween = new Tween(recBar,"y",Strong.easeOut, - recBar.height,0,1,true);
}
}

private function stopRecording(e:MouseEvent):void
{
recorder.stop();

mic.setLoopBack(false);
e.target.gotoAndStop(1);

recButton.removeEventListener(MouseEvent.MOUSE_UP, stopRecording);
recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);

tween = new Tween(recBar,"y",Strong.easeOut,0, - recBar.height,1,true);
}

private function updateMeter(e:Event):void
{
activity.gotoAndPlay(100 - mic.activityLevel);
}

private function recording(e:RecordingEvent):void
{
var currentTime:int = Math.floor(e.time / 1000);

recBar.counter.text = String(currentTime);

if (String(currentTime).length == 1)
{
recBar.counter.text = "00:0" + currentTime;
}
else if (String(currentTime).length == 2)
{
recBar.counter.text = "00:" + currentTime;
}
}

private function recordComplete(e:Event):void
{
fileReference.save(recorder.output, recordedFileName);
}
}

但保存时,文件名是包含 HTML 文件的文件夹的名称。

任何帮助将不胜感激。

最佳答案

您没有正确设置 swfObject。

var flashvars = { };
flashvars.fileName= "FILENAME_I_WANT_TO_USE";

var params = {};
params.allowscriptaccess = "always";

var attributes = {};
attributes.id = "flashContent";
attributes.name = "flashContent";
attributes.align = "middle";

var tmp = "expressInstall.swf";
var version = "9.0.0";
var width = "350";
var height = "350";
var container = "myAlternativeContent"
var flashObj = "dev_LMP.swf?t=" + new Date().getTime()

swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes);

关于javascript - 如何通过Flash保存录制的音频,文件名通过chrome中的javascript传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21259095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com