HTML5音频和视频元素不断获得Chrome的许可

时间:2015-12-03 08:32:11

标签: html asp.net html5 html5-video html5-audio

我在一个简单的aspx页面中有一个index = Int(0) let mutableComposition = AVMutableComposition() var currentTime = kCMTimeZero // Transition relate let timeOffsetBetweenVideos = CMTimeMakeWithSeconds(1, 30) let videoComposition = AVMutableVideoComposition() var videoCompInstructions: [AVMutableVideoCompositionInstruction] = [] let compositionAudioTrack = mutableComposition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: kCMPersistentTrackID_Invalid) var lastCompositionVideoTrack: AVMutableCompositionTrack? = nil for asset in movieAssets as! [AVAsset] { // Add video track into composition let compositionVideoTrack = mutableComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: kCMPersistentTrackID_Invalid) let videoTrack = asset.tracksWithMediaType(AVMediaTypeVideo)[0] try compositionVideoTrack.insertTimeRange(videoTrack.timeRange, ofTrack: videoTrack, atTime: currentTime) compositionVideoTrack.scaleTimeRange(videoTrack.timeRange, toDuration: CMTimeAdd(asset.duration, timeOffsetBetweenVideos)) // Add audio track into composition let audioTrack = asset.tracksWithMediaType(AVMediaTypeAudio)[0] try compositionAudioTrack.insertTimeRange(audioTrack.timeRange, ofTrack: audioTrack, atTime: currentTime) if index > 0 { let fromLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: lastCompositionVideoTrack!) let transitionTimeRange = CMTimeRangeMake(currentTime, timeOffsetBetweenVideos) fromLayerInstruction.setOpacityRampFromStartOpacity(1.0, toEndOpacity: 0.5, timeRange: transitionTimeRange) let toLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: compositionVideoTrack) toLayerInstruction.setOpacityRampFromStartOpacity(0.5, toEndOpacity: 1.0, timeRange: transitionTimeRange) let videoCompositionInstruction = AVMutableVideoCompositionInstruction() videoCompositionInstruction.timeRange = transitionTimeRange videoCompositionInstruction.layerInstructions = [fromLayerInstruction, toLayerInstruction] videoCompInstructions.append(videoCompositionInstruction) } lastCompositionVideoTrack = compositionVideoTrack lastVideoTrack = videoTrack currentTime = CMTimeAdd(currentTime, asset.duration) ++index } let exportSesstion = AVAssetExportSession(asset: mutableComposition, presetName: AVAssetExportPresetHighestQuality) exportSesstion?.outputFileType = AVFileTypeQuickTimeMovie exportSesstion?.outputURL = retFileUrl if movieAssets.count > 1 { videoComposition.instructions = videoCompInstructions videoComposition.renderSize = mutableComposition.naturalSize print("frame size: \(mutableComposition.naturalSize)") videoComposition.renderScale = 1.0 videoComposition.frameDuration = CMTimeMake(1, 30) exportSesstion?.videoComposition = videoComposition } exportSesstion?.exportAsynchronouslyWithCompletionHandler({ () -> Void in if exportSesstion?.status == AVAssetExportSessionStatus.Completed { print("Video file exported: \(retFileUrl)") } else { print(exportSesstion!.error!) print("Failed exporting video: \(exportSesstion?.error?.localizedDescription)") print(exportSesstion?.error?.localizedFailureReason) } }) <video>元素 我有一个脚本加载在body load事件上,它实例化了一个记录器JS类 每当页面回发时,我都会收到来自Chrome的权限消息:

enter image description here

点击&#34;允许&#34;只允许一次。在下一个回发中,该消息再次出现。有任何建议如何解决这个问题?

注意:这仅在我的生产环境中发生。当我在我的QA环境中运行此操作(使用Chrome)时,我只需点击&#34;允许&#34;一旦该消息不再出现。

1 个答案:

答案 0 :(得分:0)

通过将页面切换为HTTPS来解决。