javascriptquicktime.docx

上传人:b****7 文档编号:9738217 上传时间:2023-02-06 格式:DOCX 页数:13 大小:37.65KB
下载 相关 举报
javascriptquicktime.docx_第1页
第1页 / 共13页
javascriptquicktime.docx_第2页
第2页 / 共13页
javascriptquicktime.docx_第3页
第3页 / 共13页
javascriptquicktime.docx_第4页
第4页 / 共13页
javascriptquicktime.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

javascriptquicktime.docx

《javascriptquicktime.docx》由会员分享,可在线阅读,更多相关《javascriptquicktime.docx(13页珍藏版)》请在冰豆网上搜索。

javascriptquicktime.docx

javascriptquicktime

HowtoUseJavascripttoControlQuicktime(eithersoundorvideo)

byStephenWilson,Professor,ConceptualInformationArtsProgram,ArtDept,SFSU

Javascriptcontrolofsoundandvideoishighlyspecifictothebrowser,theversionofthebrowser,theplug-in, theoperatingsystem,andtheformatofthefileused Writingroutinesthatwillworkacrossallthesevariationsiscomplex. Therearedifferentcodeforembeddingfiles,differentsetsofjavascriptcommandsavailable,anddifferentjavascriptsyntaxforaddressingthefiles. ItisworththeeffortbecauseJavascriptenablesyoutocreateyourownvisualinterfacestomedia(thusnotrelyingonthestandardcontrollers)andtodynamicallycontrolfeaturesofthemediasuchasstart,stop,pause,locationtoplay,volume,etc. TheexamplebelowillustratesuseofQuicktimetocontrolsoundandmovies. Itassumesyouhavetheappropriatequicktimepluginforyourbrowserandoperatingsystem. Seeapple'ssitefordownloadingtheapproriateplug-in. Alsowiththeconstantchangeofbrowsers,theseexamplesmightnotworkwithyoursystem.

UnfortunatelyatthetimeofcompilingthisresourcetherewerenoadequateguidesortutorialsforusingJavascripttocontrolquicktime. EvenApple'ssitewassketchy. Herearesomelinksthatmightbeuseful:

∙Infoartsgeneralguideonhowtoauthorwebpagesthatincludesound

∙InfoArtsquickguidetoQuickTimeontheWeb

∙InfoartshowtoguidelistingoflinkstoappleandothertuoritalsonQuicktimeandJavascriptcontrolofJavascript

∙InfoartshowtoguidelistingoflinkstoJavascripttutorials

∙InfoartsguideonhowtousejavascripttocontrolNetscape'sLiveAudioplugin(LiveAudiowasthemainplug-inusedbyNetscape tocontrolAudiobutnowotherplug-inshavecomeintoprevalence.)

**LimitationsontheseExamples-NetscapeOnlyforNow-DocumentObjectModels(DOM)

Unfortunately,theexamplesbelowwillonlyworkreliablywithNetscapeNavigator4fornow. IdiosyncraciesintheMacintoshversionofInternetExplorerdevelopmentleftouttheabilityofJavascripttotalktoQuicktimeinExplorer4and5.   FurthermoretheW3organization'sstandardsforaddressingobjectsonapagemeansthattheexamplesherewillprobablynotworkinNetscape6+andExplorer6+ Theauthorwillcontinuetoworkontheproblems.

Theproblemsareworthexploringbecausetheyillustratethecurrentcomplexities. Javascriptrequirestheabilitytoidentifytheobjectinthewebpagethatistobeactedon. ThemethodforindicatingobjectsiscalledtheDocumentObjectModelorDOM. Navigator,Explorer,andtheW3orgallusedifferentmethodsoflocatingobjectsonapage.

 

 

 

ThereareotherapproachespossiblewithInternetExplorer. The bgsoundmethodofembeddingsoundsalsoallowsuseofJavascript. Althoughdetailscannotbeofferedhere,pleasevisitMicrosoftDeveloperNetworkinformationonbgsoundforlistingofpossiblecommands. Also,seeDrJavascript'spagesonuseofactiveXtocontrolaudioinExplorer-EmbeddingSoundinWebPages,PartI:

AudioControlExampleCode-DocJavaScript.Theexamplesbelowshouldbeusefulbecauseuseoftheseotherjavascriptsystemswouldbesimilartowhatispresentedhere.  Althoughitisbeyondthescopeofthistutorial,itmightbepossibletowriteJavascriptfunctionsthatuseddetectionofbrowser,version,andostomakeroutinesthatwouldworkinmostsituations.,

EmbeddingtheQuicktimefileinwebpages.

Differentbrowsersrequiredifferentcommandstoembedfiles. AtthetimeofwritingthispagethenewestInternetExplorerwasusingtheOBJECTtagandNavigatorwasusingtheEMBEDtag. Thecodebelowshouldworkonmostbrowserssinceitusesbothmethods. TheclassidisrequiredbyExplorertoidentifythequicktimeplugin. Thenumberisreference#setbyApplefortheactiveXidentifierforQuicktimeplug-in. Aviewermightneedtodownloadthequicktimeplug-insincemicrosoftquitincludingitautomaticallywiththeIEbrowser.

Theexampleillustratesloadingtwofiles. Oneisamidisoundfilecalled"Jesu-Joy.mid"andtheotherisaquicktimemoviefilecalled"test.mov". Yoursrcwouldneedtoincludethefullorrelativeurlleadingtowhereyourfilesarestored. (2filesareloadedherejustforthesakeofthisexample). EachfileneedsanameoridassignedbecauseJavascriptwouldneedtheesepropertiestodirectcommands. Theid/nameofthefirstoneisdeclaredtobe"jesu"andthesecondisdeclaredas"test". TheseOBJECTsequencesareplacedwithintheBODYhtmltags. ThisexampleisbasedonresourcesforanAppledeveloperWhat'sNewwebpageonQuicktime.

Theheightandwidthwouldneedtobesetappropriatelyforyourfiles. Alsonotethesettingofthepropertyenablejavascript="true". ThisisrequiredtomakeQuicktimeabletorespondtoJavascriptcommands. Alsoyouneedtotreatthesequicktimefilesasvisualelementsofyourpageandusehtml,styles,tables,etctopositionthemonthepage.Thisexampleplacesthe2filessidebysideina2columntable; otherhtmlpageelementshavebeenomittedintheexamplecode.

LoadingtwofilesbyObjectandEmbedmethod

----(otherhtmlcode)

----

02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"

                     codebase="

                     width="180"height="160"

                     id="jesu">

              

              

                     src="jesu-joy.mid"

                     name="jesu"

                     enablejavascript="true"

                     autostart="false">

              

 

             

02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"

                     codebase="

                     width="180"height="160"

                     id="test">

              

 

              

                     src="test.mov"

                     name="test"

                     enablejavascript="true"

                   controller="true"

autostart="false">

              

  

----(otherhtmlcode)

----

BuildingLinksorButtonsorImagemapstoactivatetheJavascriptcommands

Hereisasampleofthe JavascriptcommandsQuicktimeunderstands:

 movnameisthenameassignedwiththeobjectorembedloadedthefile.

∙movname.Play()

∙movname.Stop()

∙movname.rewind()

∙movname.SetRate(rate) 1=normalrate; 2+=quickspeed; 0=paused;-1...=backwards

∙movname.SetTime(time) For.movfilestimeisindicatedbynumberofframes-forexamplefora6framepersecondmoviesetTime(30)wouldtakeitto30thframeor5seconds.Forsoundthetimeisindicatedinmiliseconds-forexample,22000(22x1000)wouldtakeitto22thsecond. **notethissettingisdifferentthanthehour:

minute:

second:

framenotationusedintheembedtag.

∙movname.SetVolume(vol)

∙movname.SetStartTime(time)setsstarttimeforloopingusinghours:

minutes:

seconds:

framenotation

∙movname.SetEndTime(time)setsendtimeforloopingusinghours:

minutes:

seconds:

framenotation

ThesecommandscanbeuseddirectlyattachedtolinksorbuttonsorincorporatedintomorecomplexJavascriptfuntions.  Thecommandneedstoreferencethemovieandtheninvokethejavascriptcommand.Themethodofidentifyingthemovieobjectcandifferindifferentbrowsers. Theexamplesbelowillustratereferringbyname"document.jesu"andreferringbythearrayJavascriptkeepsofallobjectsthathavebeenloaded.Snce"jesu"wasthefirstoneloadeditwasthe0thitemoftheembedsarray-embeds(0). Intheseexamples regularHREFhtmlisusedbuttheurlisreplacedwiththecalltojavascript. **Notethereareothercommandsavailable;seetheAppledeveloperWhat'sNewwebpageonQuicktime. Hereisalistofthejavascriptcommandslistedonthatpage.

 

voidPlay(

voidStop()

Step(intcount)

SetRate(floatrate)

GetRate()

SetTime(inttime)

GetTime()

SetVolume(intvolume)

GetVolume()

SetMovieName(stringmovieName)

GetMovieName()

SetMovieID(intmovieID)

GetMovieID()

SetStartTime(inttime)

GetStartTime()

 SetEndTime(inttime)

GetEndTime()

SetIsLooping(booleanloop)

GetIsLooping()

SetLoopIsPalindrome(booleanloop)

GetLoopIsPalindrome()

GetMute()

SetMute(booleanmute)

SetBgColor(stringcolor)

GetBgColor()

StartingandStopping:

Herearesomelinksthatusethevariousmethodsofaddressingtocausethemoviestostopandstart.

 

Callinganobject(referencedbyname)methoddirectly

javascript:

document.jesu.Play()

javascript:

document.jesu.Stop()

javascript:

document.test.Play()

javascript:

document.test.Stop()

Callinganobject(indexedinthedocument"embeds"arraybyindex)methoddirectly

javascript:

document.embeds[0].Play()

javascript:

document.embeds[0].Stop()

javascript:

document.embeds[1].Play()

javascript:

document.embeds[1].Stop()

Callinganobject(indexedinthedocument"embeds"arraybyname)methoddirectly

javascript:

document.embeds['jesu].Play()

javascript:

document.embeds['jesu'].Stop()

javascript:

document.embeds['test'].Play()

javascript:

document.embeds['test'].Stop()

Hereisasampleofthecompletehtmlcode

document.jesu.Play();">javascript:

document.jesu.Play()

TheW3orgnewDOMstandardsusethe"getElementByID"toidentifyobjects. Thisstandardhasbeenpartiallyadoptedby

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 财会金融考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1