source stringlengths 14 113 | code stringlengths 10 21.3k |
|---|---|
application-dev\media\image\image-picture-encoding.md | let packOpts: image.PackingOption = {
format: "image/jpeg",
quality: 98,
bufferSize: 10,
desiredDynamicRange: image.PackingDynamicRange.AUTO,
needsPackProperties: true
}; |
application-dev\media\image\image-picture-encoding.md | import { BusinessError } from '@kit.BasicServicesKit';
imagePackerApi.packing(picture, packOpts).then( (data : ArrayBuffer) => {
console.info('Succeeded in packing the image.'+ data);
}).catch((error : BusinessError) => {
console.error('Failed to pack the image. And the error is: ' + error);
}) |
application-dev\media\image\image-picture-encoding.md | const context : Context = getContext(this);
const path : string = context.cacheDir + "/picture.jpg";
let file = fileIo.openSync(path, fileIo.OpenMode.CREATE | fileIo.OpenMode.READ_WRITE);
imagePackerApi.packToFile(picture, file.fd, packOpts).then(() => {
console.info('Succeeded in packing the image to file.')... |
application-dev\media\image\image-pixelmap-operation.md | import { image } from '@kit.ImageKit';
// Obtain the total number of bytes of this PixelMap object.
let pixelBytesNumber : number = pixelMap.getPixelBytesNumber();
// Obtain the number of bytes per row of this PixelMap object.
let rowBytes : number = pixelMap.getBytesNumberPerRow();
// Obtain the pixel d... |
application-dev\media\image\image-pixelmap-operation.md | import { BusinessError } from '@kit.BasicServicesKit';
// Scenario 1: Read and modify data of the entire image.
// Read the pixel data of the PixelMap based on the PixelMap's pixel format and write the data to the buffer.
const buffer = new ArrayBuffer(pixelBytesNumber);
pixelMap.readPixelsToBuffer(buffer).... |
application-dev\media\image\image-pixelmap-operation.md | /**
* Clone (deep copy) a PixelMap.
*
* @param pixelMap - PixelMap to clone.
* @param desiredPixelFormat - Pixel format of the new PixelMap. If this parameter is not specified, the pixel format of the current PixelMap is used.
* @return Returns a new PixelMap.
**/
clonePi... |
application-dev\media\image\image-receiver.md | import { image } from '@kit.ImageKit';
let imageWidth: number = 1920; // Use the width in the profile size supported by the device.
let imageHeight: number = 1080; // Use the height in the profile size supported by the device.
async function initImageReceiver():Promise<void>{
// Create an ImageReceiv... |
application-dev\media\image\image-receiver.md | import { BusinessError } from '@kit.BasicServicesKit';
import { image } from '@kit.ImageKit';
function onImageArrival(receiver: image.ImageReceiver): void {
// Subscribe to the imageArrival event.
receiver.on('imageArrival', () => {
// Obtain an image.
receiver.readNextImage((err: B... |
application-dev\media\image\image-receiver.md | // For example, for NV21 (images in YUV_420_SP format), the formula for calculating the YUV_420_SP memory is as follows: YUV_420_SP memory = Width * Height + (Width * Height)/2.
const dstBufferSize = width * height * 1.5;
const dstArr = new Uint8Array(dstBufferSize);
// Read the buffer data line by line.
... |
application-dev\media\image\image-receiver.md | // Create a PixelMap, with width set to the value of stride.
let pixelMap = await image.createPixelMap(imgComponent.byteBuffer, {
size:{height: height, width: stride}, srcPixelFormat: 8});
// Crop extra pixels.
pixelMap.cropSync({size:{width:width, height:height}, x:0, y:0}); |
application-dev\media\image\image-tool.md | // Import the required module.
import { image } from '@kit.ImageKit';
// Obtain the sandbox path and create an ImageSource object.
const fd : number = 0; // Obtain the file descriptor of the image to be processed.
const imageSourceApi : image.ImageSource = image.createImageSource(fd); |
application-dev\media\image\image-tool.md | import { BusinessError } from '@kit.BasicServicesKit';
// Read the EXIF data, where BitsPerSample indicates the number of bits per pixel.
let options : image.ImagePropertyOptions = { index: 0, defaultValue: '9999' }
imageSourceApi.getImageProperty(image.PropertyKey.BITS_PER_SAMPLE, options).then((data : str... |
application-dev\media\image\image-transformation.md | import { BusinessError } from '@kit.BasicServicesKit';
// Obtain the image size.
pixelMap.getImageInfo().then( (info : image.ImageInfo) => {
console.info('info.width = ' + info.size.width);
console.info('info.height = ' + info.size.height);
}).catch((err : BusinessError) => {
console.error("Fail... |
application-dev\media\image\image-transformation.md | // x: x-axis coordinate of the start point for cropping (0).
// y: y-axis coordinate of the start point for cropping (0).
// height: height after cropping (400), cropping from top to bottom.
// width: width after cropping (400), cropping from left to right.
pixelMap.crop({x: 0, y: 0, size: { height:... |
application-dev\media\image\image-transformation.md | // The width of the image after scaling is 0.5 of the original width.
// The height of the image after scaling is 0.5 of the original height.
pixelMap.scale(0.5, 0.5); |
application-dev\media\image\image-transformation.md | // Translate the image by 100 units downwards.
// Translate the image by 100 units rightwards.
pixelMap.translate(100, 100); |
application-dev\media\image\image-transformation.md | // Rate the image clockwise by 90°.
pixelMap.rotate(90); |
application-dev\media\image\image-transformation.md | // Flip the image vertically.
pixelMap.flip(false, true); |
application-dev\media\image\image-transformation.md | // Flip the image horizontally.
pixelMap.flip(true, false); |
application-dev\media\image\image-transformation.md | // Set the opacity to 0.5.
pixelMap.opacity(0.5); |
application-dev\media\media\avimagegenerator.md | import { media } from '@kit.MediaKit';
import { image } from '@kit.ImageKit';
import { common } from '@kit.AbilityKit';
const TAG = 'MetadataDemo';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
// Declare a pixelMap object, which is used for image display.
@State pixelMap: image.Pixel... |
application-dev\media\media\avmetadataextractor.md | import { media } from '@kit.MediaKit';
import { image } from '@kit.ImageKit';
import { common } from '@kit.AbilityKit';
import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit';
const TAG = 'MetadataDemo';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
// Declare a pixelMap object, w... |
application-dev\media\media\avtranscoder-practice.md | import { ErrorEvent, MessageEvents, worker } from '@kit.ArkTS'
import { SendableObject } from '../util/SendableObject';
import { common, sendableContextManager } from '@kit.AbilityKit'; |
application-dev\media\media\avtranscoder-practice.md | // Create a Worker object.
this.workerInstance = new worker.ThreadWorker('entry/ets/workers/task.ets');
// Register the onmessage callback. When the host thread receives a message from the Worker thread through the workerPort.postMessage interface,
// this callback is invoked and executed in the host thread.
... |
application-dev\media\media\avtranscoder-practice.md | import { sendableContextManager } from '@kit.AbilityKit';
@Sendable
export class SendableObject {
constructor(sendableContext: sendableContextManager.SendableContext, data: string = '') {
this.sendableContext = sendableContext;
this.data = data;
}
private sendab... |
application-dev\media\media\avtranscoder-practice.md | // Send a message to the Worker thread.
this.context = this.getUIContext().getHostContext();
const sendableContext: sendableContextManager.SendableContext = sendableContextManager.convertFromContext(this.context);
const sendableObject: SendableObject = new SendableObject(sendableContext, "some information")... |
application-dev\media\media\avtranscoder-practice.md | // Receive the parameters.
const sendableObject: SendableObject = event.data;
const sendableContext: sendableContextManager.SendableContext =
sendableObject.getSendableContext() as sendableContextManager.SendableContext;
const context: common.Context =
sendableContextManager.convertToContext(sendabl... |
application-dev\media\media\avtranscoder-practice.md | async function doSome(context: common.Context) {
console.info(`doSome in`);
try {
let transcoder = await media.createAVTranscoder();
// Callback function for the completion of transcoding.
transcoder.on('complete', async () => {
console.info(`transcode... |
application-dev\media\media\avtranscoder-practice.md | transcoder.on('complete', async () => {
console.info(`transcode complete`);
await transcoder?.release()
// Send a message to the main thread, indicating that the transcoding is complete.
workerPort.postMessage('complete');
}) |
application-dev\media\media\avtranscoder-practice.md | // Register the onmessage callback. When the host thread receives a message from the Worker thread through the workerPort.postMessage interface, this callback is invoked and executed in the host thread.
this.workerInstance.onmessage = (e: MessageEvents) => {
let data: string = e.data;
conso... |
application-dev\media\media\avtranscoder-practice.md | import { ErrorEvent, MessageEvents, worker } from '@kit.ArkTS'
import { SendableObject } from '../util/SendableObject';
import { common, sendableContextManager } from '@kit.AbilityKit';
@Entry
@Component
struct Index {
private workerInstance?: worker.ThreadWorker;
private context: Context | undefined;
bui... |
application-dev\media\media\avtranscoder-practice.md | import { sendableContextManager } from '@kit.AbilityKit';
// Decorate the parameters with @Sendable.
@Sendable
export class SendableObject {
constructor(sendableContext: sendableContextManager.SendableContext, data: string = '') {
this.sendableContext = sendableContext;
this.data = data;
}
... |
application-dev\media\media\avtranscoder-practice.md | import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS';
import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import fs from '@ohos.file.fs';
import { SendableObject } from '../util/SendableObject';
import { common, sendableContextManager } from '... |
application-dev\media\media\playback-url-setting-method.md | // Set the URL of the media asset to play.
let url = 'https://xxx.xxx.xxx.mp4';
this.avPlayer.url = url; |
application-dev\media\media\playback-url-setting-method.md | // Set the URL of the media asset to play.
let url = 'https://xxx.xxx.xxx.xxx:xx/xx/index.m3u8';
this.avPlayer.url = url; |
application-dev\media\media\playback-url-setting-method.md | // Set the URL of the media asset to play.
let url = 'https://xxx.xxx.xxx.xxx:xx/xx/index.m3u8';
// Create a mediaSource instance, set the media source, and customize an HTTP request. If necessary, set fields such as User-Agent, Cookie, and Referer in key-value pairs.
let mediaSource : media.MediaSource = media.c... |
application-dev\media\media\playback-url-setting-method.md | // Obtain the file descriptor based on the local M3U8 file name.
let fileDescriptor = await this.context.resourceManager.getRawFd('xxx.m3u8');
// Use the file descriptor to construct the URL of the local M3U8 file.
let fdUrl : string = "fd://" + fileDescriptor.fd +
"?offset=" + fileDescriptor.offset + "&size=... |
application-dev\media\media\playback-url-setting-method.md | let filePath = "/data/storage/el1/bundle/${m3u8FileName}";
// Obtain the file handle through fs.openSync.
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let fd : string = file.fd.toString();
// Use the file handle to construct the URL of the local M3U8 file.
let fdUrl : string = "fd://" + fd + "?off... |
application-dev\media\media\playback-url-setting-method.md | import { common } from '@kit.AbilityKit';
private context: Context | undefined;
constructor(context: Context) {
this.context = context; // this.getUIContext().getHostContext();
}
// Create an AVPlayer instance.
let avPlayer: media.AVPlayer = await media.createAVPlayer();
let fdPath = 'fd://';
// Obtai... |
application-dev\media\media\playback-url-setting-method.md | // Call getRawFd of the resourceManager member of UIAbilityContext to obtain the media asset URL.
// The return type is {fd,offset,length}, where fd indicates the file descriptor address of the HAP file, offset indicates the media asset offset, and length indicates the duration of the media asset to play.
let fileD... |
application-dev\media\media\streaming-media-playback-development-guide.md | this.avPlayer.on('bufferingUpdate', (infoType : media.BufferingInfoType, value : number) => {
console.info(`AVPlayer bufferingUpdate, infoType is ${infoType}, value is ${value}.`);
}) |
application-dev\media\media\streaming-media-playback-development-guide.md | // Create an AVPlayer instance.
this.avPlayer: media.AVPlayer = await media.createAVPlayer();
// Listen for the available bit rates of the current HLS stream.
this.avPlayer.on('availableBitrates', (bitrates: Array<number>) => {
console.info('availableBitrates called, and availableBitrates length is: '... |
application-dev\media\media\streaming-media-playback-development-guide.md | // Create an AVPlayer instance.
this.avPlayer: media.AVPlayer = await media.createAVPlayer();
// Check whether the bit rate setting takes effect.
this.avPlayer.on('bitrateDone', (bitrate: number) => {
console.info('bitrateDone called, and bitrate value is: ' + bitrate);
})
// Set the playback ... |
application-dev\media\media\streaming-media-playback-development-guide.md | let mediaSource : media.MediaSource = media.createMediaSourceWithUrl("http://test.cn/dash/aaa.mpd", {"User-Agent" : "User-Agent-Value"});
let playbackStrategy : media.PlaybackStrategy = {preferredWidth: 1920, preferredHeight: 1080};
this.avPlayer.setMediaSource(mediaSource, playbackStrategy); |
application-dev\media\media\streaming-media-playback-development-guide.md | this.avPlayer.on('trackChange', (index: number, isSelect: boolean) => {
console.info(`trackChange info, index: ${index}, isSelect: ${isSelect}`);
}) |
application-dev\media\media\streaming-media-playback-development-guide.md | // The following uses the 1080p video track index as an example.
this.avPlayer.getTrackDescription((error: BusinessError, arrList: Array<media.MediaDescription>) => {
if (arrList != null) {
for (let i = 0; i < arrList.length; i++) {
let propertyIndex: Object = arrList[i][media.MediaDescripti... |
application-dev\media\media\streaming-media-playback-development-guide.md | // Select a video track.
avPlayer.selectTrack(videoTrackIndex);
// Deselect the video track.
// avPlayer.deselectTrack(videoTrackIndex); |
application-dev\media\media\streaming-media-playback-development-guide.md | @Entry
@Component
struct Index {
private avPlayer: media.AVPlayer | null = null;
private context: common.UIAbilityContext | undefined = undefined;
public videoTrackIndex: number = 0;
public bitrate: number = 0;
...
getDurationTime(): number {
return this.durationTime;
}
getCurrentTime(): number {
... |
application-dev\media\media\using-avplayer-for-playback.md | import display from '@ohos.display';
import emitter from '@ohos.events.emitter';
import { common } from '@kit.AbilityKit';
import media from '@ohos.multimedia.media';
...
@Entry
@Component
struct Index {
private avPlayer: media.AVPlayer | null = null;
private context: common.UIAbilityContext | undefined = undefin... |
application-dev\media\media\using-avrecorder-for-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
let avRecorder: media.AVRecorder;
media.createAVRecorder().then((recorder: media.AVRecorder) => {
avRecorder = recorder;
}, (error: BusinessError) => {
console.error(`createAVRecorder failed`);
}) |
application-dev\media\media\using-avrecorder-for-recording.md | import { BusinessError } from '@kit.BasicServicesKit';
// Callback function for state changes.
this.avRecorder.on('stateChange', (state: media.AVRecorderState, reason: media.StateChangeReason) => {
console.log(`current state is ${state}`);
// You can add the action to be performed after the state is sw... |
application-dev\media\media\using-avrecorder-for-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs } from '@kit.CoreFileKit';
let avProfile: media.AVRecorderProfile = {
audioBitrate: 100000, // Audio bit rate.
audioChannels: 2, // Number of audio channels.
audioCodec: media.Cod... |
application-dev\media\media\using-avrecorder-for-recording.md | // Start recording.
avRecorder.start(); |
application-dev\media\media\using-avrecorder-for-recording.md | // Pause recording.
avRecorder.pause(); |
application-dev\media\media\using-avrecorder-for-recording.md | // Resume recording.
avRecorder.resume(); |
application-dev\media\media\using-avrecorder-for-recording.md | // Stop recording.
avRecorder.stop(); |
application-dev\media\media\using-avrecorder-for-recording.md | // Reset resources.
avRecorder.reset(); |
application-dev\media\media\using-avrecorder-for-recording.md | // Destroy the instance.
avRecorder.release(); |
application-dev\media\media\using-avrecorder-for-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs } from '@kit.CoreFileKit';
export class AudioRecorderDemo extends CustomComponent {
private avRecorder: media.AVRecorder | undefined = undefined;
private avProfile: media.AVRecorderProfile = {
au... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
let avTranscoder: media.AVTranscoder | undefined = undefined;
media.createAVTranscoder().then((transcoder: media.AVTranscoder) => {
avTranscoder = transcoder;
// Perform other operations after avTranscod... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import { BusinessError } from '@kit.BasicServicesKit';
// Callback function for the completion of transcoding.
avTranscoder.on('complete', async () => {
console.log(`transcoder is completed`);
// Listen for the transcoding completion event and call release.
// Wait until avTranscoder.release() ... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import {AVTranscoderDemo} from '../transcoder/AVTranscoderManager'
@Entry
@Component
struct Index {
private context:Context | undefined = this.getUIContext().getHostContext();
private avTranscoder: AVTranscoderDemo = new AVTranscoderDemo(this.context);
build() {
Column() {
Button... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import resourceManager from '@ohos.resourceManager';
import { common } from '@kit.AbilityKit';
private context: Context | undefined;
constructor(context: Context | undefined) {
if (context != undefined) {
this.context = context; // this.getUIContext().getHostContext();
}
}
// Obtain... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Set the sandbox path of the output target file.
let outputFilePath = this.context.filesDir + "/output.mp4";
// Create and open a file if the file does not exist. Open it if the file exists.
let file = fs.openSync(outputFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
// Set fdDst of the output fil... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
let avConfig: media.AVTranscoderConfig = {
audioBitrate: 100000, // Audio bit rate.
audioCodec: media.CodecMimeType.AUDIO_AAC, // Audio encoding format.
fileFormat: media.ContainerFormatType.CFT_MPEG_4... |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Start transcoding.
avTranscoder.start(); |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Pause transcoding.
avTranscoder.pause(); |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Resume transcoding.
avTranscoder.resume(); |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Cancel transcoding.
avTranscoder.cancel(); |
application-dev\media\media\using-avtranscoder-for-transcodering.md | // Destroy the instance.
avTranscoder.release(); |
application-dev\media\media\using-avtranscoder-for-transcodering.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import fs from '@ohos.file.fs';
export class AVTranscoderDemo {
private avTranscoder: media.AVTranscoder | undefined = undefined;
private context: Context | undefined;
construct... |
application-dev\media\media\using-soundpool-for-playback.md | import { media } from '@kit.MediaKit';
import { audio } from '@kit.AudioKit';
import { BusinessError } from '@kit.BasicServicesKit';
let soundPool: media.SoundPool;
// If the value of usage in audioRenderInfo is STREAM_USAGE_UNKNOWN, STREAM_USAGE_MUSIC, STREAM_USAGE_MOVIE,
// or STREAM_USAGE_AUDIOB... |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.on('loadComplete', (soundId: number) => {
console.info('loadComplete, soundId: ' + soundId);
}); |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.on('playFinished', () => {
console.info("receive play finished message");
});
soundPool.on('playFinishedWithStreamId', (streamId) => {
console.info("receive play finished message, streamId: " + streamId);
}); |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.on('error', (error: BusinessError) => {
console.error('error happened,message is :' + error.message);
}); |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs } from '@kit.CoreFileKit';
let soundID: number;
let uri: string;
async function load() {
await fs.open('/test_01.mp3', fs.OpenMode.READ_ONLY).then((file: fs.File) => {
console.info("file fd: " + file.fd);
... |
application-dev\media\media\using-soundpool-for-playback.md | let soundID: number;
let streamID: number;
let playParameters: media.PlayParameters = {
loop: 0, // The sound does not loop. It is played once.
rate: 2, // The sound is played at twice its original frequency.
leftVolume: 0.5, // range = 0.0-1.0
rightVolume: 0.5, // range = 0.0-1.... |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
let streamID: number;
soundPool.setLoop(streamID, 1).then(() => {
console.info('setLoop success streamID:' + streamID);
}).catch((err: BusinessError) => {
console.error('soundpool setLoop failed and catch error is ' + err.message);
}); |
application-dev\media\media\using-soundpool-for-playback.md | let streamID: number;
soundPool.setPriority(streamID, 1); |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
let streamID: number;
// Call play() to obtain the stream ID.
soundPool.setVolume(streamID, 0.5, 0.5).then(() => {
console.info('setVolume success');
}).catch((err: BusinessError) => {
console.error('soundpool setVolume failed and catc... |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
let streamID: number;
// Call play() to obtain the stream ID.
soundPool.stop(streamID).then(() => {
console.info('stop success');
}).catch((err: BusinessError) => {
console.error('soundpool load stop and catch error is ' + err.message)... |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
let soundID: number;
// Call load() to obtain the sound ID.
soundPool.unload(soundID).then(() => {
console.info('unload success');
}).catch((err: BusinessError) => {
console.error('soundpool unload failed and catch error is ' + err.mes... |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.off('loadComplete'); |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.off('playFinished'); |
application-dev\media\media\using-soundpool-for-playback.md | soundPool.off('error'); |
application-dev\media\media\using-soundpool-for-playback.md | import { BusinessError } from '@kit.BasicServicesKit';
soundPool.release().then(() => {
console.info('release success');
}).catch((err: BusinessError) => {
console.error('soundpool release failed and catch error is ' + err.message);
}); |
application-dev\media\media\using-soundpool-for-playback.md | import { audio } from '@kit.AudioKit';
import { media } from '@kit.MediaKit';
import { fileIo as fs } from '@kit.CoreFileKit';
import { BusinessError } from '@kit.BasicServicesKit';
let soundPool: media.SoundPool;
let streamId: number = 0;
let soundId: number = 0;
// If the value of usage in audioRenderInfo is STREAM_... |
application-dev\media\media\video-playback.md | import display from '@ohos.display';
import emitter from '@ohos.events.emitter';
import { common } from '@kit.AbilityKit';
import media from '@ohos.multimedia.media';
...
@Entry
@Component
struct Index {
private avPlayer: media.AVPlayer | null = null;
private context: common.UIAbilityContext | undefined = undefin... |
application-dev\media\media\video-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
let avRecorder: media.AVRecorder;
media.createAVRecorder().then((recorder: media.AVRecorder) => {
avRecorder = recorder;
}, (error: BusinessError) => {
console.error('createAVRecorder failed');
}) |
application-dev\media\media\video-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
// Callback function for state changes.
this.avRecorder.on('stateChange', (state: media.AVRecorderState, reason: media.StateChangeReason) => {
console.info('current state is: ' + state);
})
// Callback fun... |
application-dev\media\media\video-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs } from '@kit.CoreFileKit';
let avProfile: media.AVRecorderProfile = {
fileFormat: media.ContainerFormatType.CFT_MPEG_4, // Video file container format. Only MP4 is supported.
videoBitr... |
application-dev\media\media\video-recording.md | import { BusinessError } from '@kit.BasicServicesKit';
this.avRecorder.getInputSurface().then((surfaceId: string) => {
console.info('avRecorder getInputSurface success');
}, (error: BusinessError) => {
console.error('avRecorder getInputSurface failed');
}) |
application-dev\media\media\video-recording.md | import { media } from '@kit.MediaKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { fileIo as fs, fileUri } from '@kit.CoreFileKit';
import { photoAccessHelper } from '@kit.MediaLibraryKit';
const TAG = 'VideoRecorderDemo:';
export class VideoRecorderDemo extends CustomComponent {
private context... |
application-dev\media\media\video-subtitle.md | // Set subtitles.
let fileDescriptorSub = await this.context.resourceManager.getRawFd('xxx.srt');
this.avPlayer.addSubtitleFromFd(fileDescriptorSub.fd, fileDescriptorSub.offset, fileDescriptorSub.length); |
application-dev\media\media\video-subtitle.md | // Callback function for subtitle updates.
this.avPlayer.on('subtitleUpdate', (info: media.SubtitleInfo) => {
if (!!info) {
let text = (!info.text) ? '' : info.text;
let startTime = (!info.startTime) ? 0 : info.startTime;
let duration = (!info.duration) ? 0 : info.duration;
con... |
application-dev\media\media\video-subtitle.md | this.avPlayer?.off('subtitleUpdate'); |
application-dev\media\media\video-subtitle.md | import display from '@ohos.display';
import emitter from '@ohos.events.emitter';
import { common } from '@kit.AbilityKit';
import media from '@ohos.multimedia.media';
...
@Entry
@Component
struct Index {
private avPlayer: media.AVPlayer | null = null;
private context: common.UIAbilityContext | undefined = undefin... |
application-dev\media\medialibrary\movingphotoview-guidelines.md | import { MovingPhotoView, MovingPhotoViewController, MovingPhotoViewAttribute } from '@kit.MediaLibraryKit'; |
application-dev\media\medialibrary\movingphotoview-guidelines.md | src: photoAccessHelper.MovingPhoto | undefined = undefined; |
application-dev\media\medialibrary\movingphotoview-guidelines.md | controller: MovingPhotoViewController = new MovingPhotoViewController(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.