public void playMedia(string filename, bool convert) { AVAnimatorMedia media = new AVAnimatorMedia(); media.animatorRepeatCount = 10; animatorMedia = media; genericResourceLoader(filename, convert, media); this.animatorView.attachMedia(media); this.animatorView.media.startAnimator(); }
void genericResourceLoader(string resourcePrefix, bool convertToMvid, AVAnimatorMedia media) { string videoResourceArchiveName; string videoResourceEntryName; string videoResourceOutName; string videoResourceOutPath; string mvidResFilename = string.Format("{0}.mvid.7z", resourcePrefix); string mvidResPath = NSBundle.MainBundle.PathForResource(mvidResFilename, null); bool convertToMvidLoader = true; if (convertToMvid == false) { convertToMvidLoader = false; } if (convertToMvid && (mvidResPath != null)) { // Extract existing FILENAME.mvid from FILENAME.mvid.7z attached as app resource videoResourceArchiveName = string.Format("{0}.mvid.7z", resourcePrefix); videoResourceEntryName = string.Format("{0}.mvid", resourcePrefix); string resourceTail = resourcePrefix; videoResourceOutName = string.Format("{0}.mvid", resourceTail); videoResourceOutPath = AVFileUtil.getTmpDirPath(videoResourceOutName); convertToMvidLoader = false; } else if (convertToMvid) { // Extract to /tmp/FILENAME.mvid videoResourceArchiveName = string.Format("{0}.mov.7z", resourcePrefix); videoResourceEntryName = string.Format("{0}.mov", resourcePrefix); string resourceTail = resourcePrefix; videoResourceOutName = string.Format("{0}.mvid", resourceTail); videoResourceOutPath = AVFileUtil.getTmpDirPath(videoResourceOutName); } else { // Extract to /tmp/FILENAME.mov videoResourceArchiveName = string.Format("{0}.mov.7z", resourcePrefix); videoResourceEntryName = string.Format("{0}.mov", resourcePrefix); string resourceTail = resourcePrefix; videoResourceOutName = string.Format("{0}.mov", resourceTail); videoResourceOutPath = AVFileUtil.getTmpDirPath(videoResourceOutName); } if (convertToMvidLoader) { AV7zQT2MvidResourceLoader resLoader = new AV7zQT2MvidResourceLoader(); resLoader.archiveFilename = videoResourceArchiveName; resLoader.movieFilename = videoResourceEntryName; resLoader.outPath = videoResourceOutPath; media.resourceLoader = resLoader; } else { AV7zAppResourceLoader resLoader = new AV7zAppResourceLoader(); resLoader.archiveFilename = videoResourceArchiveName; resLoader.movieFilename = videoResourceEntryName; resLoader.outPath = videoResourceOutPath; media.resourceLoader = resLoader; } if (convertToMvid) { AVMvidFrameDecoder frameDecoder = new AVMvidFrameDecoder(); media.frameDecoder = frameDecoder; } else { AVQTAnimationFrameDecoder frameDecoder = new AVQTAnimationFrameDecoder(); media.frameDecoder = frameDecoder; } return; }